DRM: Bridge: DW_HDMI: Add new features and bug fix
Subsystems (6)
v2 cover DRM: Bridge: DW_HDMI: Add new features and bug fix
This is new features and bug fix patch set for DW_HDMI DRM bridge driver that has verified by NXP i.MX8MPlus.
Three new feature added:
1. Add GPA interface for DW_HDMI Audio.
2. Add CEC PM functions to restore CEC status when device suspend/resume
3. New API for reset PHY Gen1.
Two bugs fixed:
1. Enable overflow workaround for all IP versions later than v1.30a.
2. Clear GCP_Auto bit for 24-bit color depth to pass CTS.
v1->v2:
1. Save CEC interrupt registers in struct dw_hdmi_cec
2. Restore CEC logical address register by cec->addresses.
3. Default enable overflow workaround for all versions later than v1.30a.
4. Add clear_gcp_auto flag to clear gcp_auto bit for all 24-bit color.
5. Remove i.MX8MPlus specific reference.
Sandor Yu (5):
drm: bridge: dw_hdmi: cec: Add cec suspend/resume function
drm: bridge: dw_hdmi: default enable workaround to clear the overflow
drm: bridge: dw_hdmi: Enable GCP only for Deep Color
drm: bridge: dw_hdmi: add reset function for PHY GEN1
drm: bridge: dw_hdmi: Audio: Add General Parallel Audio (GPA) driver
drivers/gpu/drm/bridge/synopsys/Kconfig | 10 + drivers/gpu/drm/bridge/synopsys/Makefile | 1 + drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 37 ++++ .../drm/bridge/synopsys/dw-hdmi-gp-audio.c | 199 ++++++++++++++++++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 177 ++++++++++++++-- drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 13 +- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 2 +- include/drm/bridge/dw_hdmi.h | 9 +- 8 files changed, 424 insertions(+), 24 deletions(-) create mode 100644 drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c
Signature · 1 line
2.25.1
PATCH v2 1/5 drm: bridge: dw_hdmi: cec: Add cec suspend/resume function
CEC interrupt status/mask and logical address registers
will be reset when device enter suspend.
It will cause cec fail to work after device resume.
Add CEC suspend/resume functions, reinitialize logical address registers and restore interrupt status/mask registers after resume.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +37 -0
@@ -62,6 +62,10 @@ struct dw_hdmi_cec {bool rx_done;struct cec_notifier *notify;int irq; + +u8 regs_polarity; +u8 regs_mask; +u8 regs_mute_stat0; };static void dw_hdmi_write (struct dw_hdmi_cec *cec,u8 val,int offset)
@@ -306,11 +310,44 @@ static int dw_hdmi_cec_remove(struct platform_device *pdev)return 0 ; } +static int __maybe_unused dw_hdmi_cec_resume (struct device *dev) +{ +struct dw_hdmi_cec *cec =dev_get_drvdata (dev); + +/* Restore logical address */ +dw_hdmi_write (cec, cec->addresses &255 ,HDMI_CEC_ADDR_L ); +dw_hdmi_write (cec, cec->addresses >>8 ,HDMI_CEC_ADDR_H ); + +/* Restore interrupt status/mask register */ +dw_hdmi_write (cec, cec->regs_polarity,HDMI_CEC_POLARITY ); +dw_hdmi_write (cec, cec->regs_mask,HDMI_CEC_MASK ); +dw_hdmi_write (cec, cec->regs_mute_stat0,HDMI_IH_MUTE_CEC_STAT0 ); + +return 0 ; +} + +static int __maybe_unused dw_hdmi_cec_suspend (struct device *dev) +{ +struct dw_hdmi_cec *cec =dev_get_drvdata (dev); + +/* store interrupt status/mask register */ + cec->regs_polarity =dw_hdmi_read (cec,HDMI_CEC_POLARITY ); + cec->regs_mask =dw_hdmi_read (cec,HDMI_CEC_MASK ); + cec->regs_mute_stat0 =dw_hdmi_read (cec,HDMI_IH_MUTE_CEC_STAT0 ); + +return 0 ; +} + +static const struct dev_pm_ops dw_hdmi_cec_pm = { +SET_SYSTEM_SLEEP_PM_OPS (dw_hdmi_cec_suspend, dw_hdmi_cec_resume) +}; +static struct platform_driver dw_hdmi_cec_driver = { .probe = dw_hdmi_cec_probe, .remove = dw_hdmi_cec_remove, .driver = { .name ="dw-hdmi-cec" , + .pm = &dw_hdmi_cec_pm, }, };module_platform_driver (dw_hdmi_cec_driver);
Signature · 1 line
2.25.1
Re: [PATCH v2 1/5] drm: bridge: dw_hdmi: cec: Add cec suspend/resume function
Quoted 61 lines · Sandor Yu
CEC interrupt status/mask and logical address registers
will be reset when device enter suspend.
It will cause cec fail to work after device resume.
Add CEC suspend/resume functions, reinitialize logical address registers and restore interrupt status/mask registers after resume.Signed-off-by Sandor Yu <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +35
-0@@ -62,6 +62,10 @@ struct dw_hdmi_cec {bool rx_done;struct cec_notifier *notify;int irq; + +u8 regs_polarity; +u8 regs_mask; +u8 regs_mute_stat0; };static void dw_hdmi_write (struct dw_hdmi_cec *cec,u8 val,int offset)@@ -306,11 +310,44 @@ static int dw_hdmi_cec_remove(struct platform_device *pdev)return 0 ; } +static int __maybe_unused dw_hdmi_cec_resume (struct device *dev) +{ +struct dw_hdmi_cec *cec =dev_get_drvdata (dev); + +/* Restore logical address */ +dw_hdmi_write (cec, cec->addresses &255 ,HDMI_CEC_ADDR_L ); +dw_hdmi_write (cec, cec->addresses >>8 ,HDMI_CEC_ADDR_H ); + +/* Restore interrupt status/mask register */ +dw_hdmi_write (cec, cec->regs_polarity,HDMI_CEC_POLARITY ); +dw_hdmi_write (cec, cec->regs_mask,HDMI_CEC_MASK ); +dw_hdmi_write (cec, cec->regs_mute_stat0,HDMI_IH_MUTE_CEC_STAT0 ); + +return 0 ; +} + +static int __maybe_unused dw_hdmi_cec_suspend (struct device *dev) +{ +struct dw_hdmi_cec *cec =dev_get_drvdata (dev); + +/* store interrupt status/mask register */ + cec->regs_polarity =dw_hdmi_read (cec,HDMI_CEC_POLARITY ); + cec->regs_mask =dw_hdmi_read (cec,HDMI_CEC_MASK ); + cec->regs_mute_stat0 =dw_hdmi_read (cec,HDMI_IH_MUTE_CEC_STAT0 ); + +return 0 ; +} + +static const struct dev_pm_ops dw_hdmi_cec_pm = { +SET_SYSTEM_SLEEP_PM_OPS (dw_hdmi_cec_suspend, dw_hdmi_cec_resume) +};
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c static int dw_hdmi_cec_remove(struct platform_device *pdev) · line 353
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +2
-0+static struct platform_driver dw_hdmi_cec_driver = { .probe = dw_hdmi_cec_probe, .remove = dw_hdmi_cec_remove, .driver = { .name ="dw-hdmi-cec" , + .pm = &dw_hdmi_cec_pm, }, };module_platform_driver (dw_hdmi_cec_driver);
As Hans said on v1, why don't you call dw_hdmi_cec_enable(cec->adap, false) in suspend and dw_hdmi_cec_enable(cec->adap, true) in resume ?
With this, CEC engine is not disabled on suspend.
Do you plan to use the engine from the suspend code ?
Neil
Jernej Škrabec
maintainerRe: [PATCH v2 1/5] drm: bridge: dw_hdmi: cec: Add cec suspend/resume function
Dne petek, 08. april 2022 ob 15:41:36 CEST je Neil Armstrong napisal(a):
Quoted 84 lines · Sandor Yu
Quoted 83 lines
CEC interrupt status/mask and logical address registers
will be reset when device enter suspend.
It will cause cec fail to work after device resume.
Add CEC suspend/resume functions, reinitialize logical address registers and restore interrupt status/mask registers after resume.Signed-off-by Sandor Yu <[email protected]>---
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.cindexc8f44bcb298a..ab176401b727100644drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +4
-0@@ -62,6 +62,10 @@ struct dw_hdmi_cec {bool rx_done;struct cec_notifier *notify;int irq; + +u8 regs_polarity; +u8 regs_mask; +u8 regs_mute_stat0;};static void
dw_hdmi_write(struct dw_hdmi_cec *cec, u8 val, int offset)drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +33
-0@@ -306,11 +310,44 @@ static int dw_hdmi_cec_remove(struct platform_device *pdev)> return 0; } +static int __maybe_unused dw_hdmi_cec_resume (struct device *dev) +{ +struct dw_hdmi_cec *cec =dev_get_drvdata (dev); + +/* Restore logical address */ +dw_hdmi_write (cec, cec->addresses &255 ,HDMI_CEC_ADDR_L ); +dw_hdmi_write (cec, cec->addresses >>8 ,HDMI_CEC_ADDR_H ); + +/* Restore interrupt status/mask register */ +dw_hdmi_write (cec, cec->regs_polarity,HDMI_CEC_POLARITY ); +dw_hdmi_write (cec, cec->regs_mask,HDMI_CEC_MASK ); +dw_hdmi_write (cec, cec->regs_mute_stat0,HDMI_IH_MUTE_CEC_STAT0 ); + +return 0 ; +} + +static int __maybe_unused dw_hdmi_cec_suspend (struct device *dev) +{ +struct dw_hdmi_cec *cec =dev_get_drvdata (dev); + +/* store interrupt status/mask register */ + cec->regs_polarity =dw_hdmi_read (cec,HDMI_CEC_POLARITY ); + cec->regs_mask =dw_hdmi_read (cec,HDMI_CEC_MASK ); + cec->regs_mute_stat0 =dw_hdmi_read (cec,HDMI_IH_MUTE_CEC_STAT0 ); + +return 0 ; +} + +static const struct dev_pm_ops dw_hdmi_cec_pm = { +SET_SYSTEM_SLEEP_PM_OPS (dw_hdmi_cec_suspend, dw_hdmi_cec_resume) +}; +static struct platform_driver dw_hdmi_cec_driver = { .probe = dw_hdmi_cec_probe, .remove = dw_hdmi_cec_remove, .driver = { .name ="dw-hdmi-cec" , + .pm = &dw_hdmi_cec_pm, },
Quoted 7 lines
Quoted 2 lines
}; module_platform_driver(dw_hdmi_cec_driver);As Hans said on v1, why don't you call
dw_hdmi_cec_enable(cec->adap, false)in suspend anddw_hdmi_cec_enable(cec->adap, true)in resume ?With this, CEC engine is not disabled on suspend.
This should not be done, at least not unconditionally. CEC wakeup functionality is used by Crust firmware for Allwinner boards. In fact, DW HDMI CEC controller was designed with suspend/resume functionality in mind. If properly set, it can autonomously scan for preset CEC messages and generate interrupt when found.
Actually, I'm not fan of this patch, since it looks like workaround for power management firmware not restoring previous state. Or is this HW issue? In any case, Allwinner SoCs with DW-HDMI CEC don't need restoring any register, so it's certainly not a general issue.
Quoted 2 lines
Do you plan to use the engine from the suspend code ?
As mentioned before, it's already done for Allwinner, so CEC should remain enabled.
Best regards,
Jernej
Quoted 2 lines
Neil
Re: [PATCH v2 1/5] drm: bridge: dw_hdmi: cec: Add cec suspend/resume function
Quoted 99 lines · Jernej Škrabec
Dne petek, 08. april 2022 ob 15:41:36 CEST je Neil Armstrong napisal(a):
Quoted 84 lines · Sandor Yu
Quoted 83 lines
CEC interrupt status/mask and logical address registers
will be reset when device enter suspend.
It will cause cec fail to work after device resume.
Add CEC suspend/resume functions, reinitialize logical address registers and restore interrupt status/mask registers after resume.Signed-off-by Sandor Yu <[email protected]>---
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.cindexc8f44bcb298a..ab176401b727100644drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +4
-0@@ -62,6 +62,10 @@ struct dw_hdmi_cec {bool rx_done;struct cec_notifier *notify;int irq; + +u8 regs_polarity; +u8 regs_mask; +u8 regs_mute_stat0;};static void
dw_hdmi_write(struct dw_hdmi_cec *cec, u8 val, int offset)drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +33
-0@@ -306,11 +310,44 @@ static int dw_hdmi_cec_remove(struct platform_device *pdev)> return 0; } +static int __maybe_unused dw_hdmi_cec_resume (struct device *dev) +{ +struct dw_hdmi_cec *cec =dev_get_drvdata (dev); + +/* Restore logical address */ +dw_hdmi_write (cec, cec->addresses &255 ,HDMI_CEC_ADDR_L ); +dw_hdmi_write (cec, cec->addresses >>8 ,HDMI_CEC_ADDR_H ); + +/* Restore interrupt status/mask register */ +dw_hdmi_write (cec, cec->regs_polarity,HDMI_CEC_POLARITY ); +dw_hdmi_write (cec, cec->regs_mask,HDMI_CEC_MASK ); +dw_hdmi_write (cec, cec->regs_mute_stat0,HDMI_IH_MUTE_CEC_STAT0 ); + +return 0 ; +} + +static int __maybe_unused dw_hdmi_cec_suspend (struct device *dev) +{ +struct dw_hdmi_cec *cec =dev_get_drvdata (dev); + +/* store interrupt status/mask register */ + cec->regs_polarity =dw_hdmi_read (cec,HDMI_CEC_POLARITY ); + cec->regs_mask =dw_hdmi_read (cec,HDMI_CEC_MASK ); + cec->regs_mute_stat0 =dw_hdmi_read (cec,HDMI_IH_MUTE_CEC_STAT0 ); + +return 0 ; +} + +static const struct dev_pm_ops dw_hdmi_cec_pm = { +SET_SYSTEM_SLEEP_PM_OPS (dw_hdmi_cec_suspend, dw_hdmi_cec_resume) +}; +static struct platform_driver dw_hdmi_cec_driver = { .probe = dw_hdmi_cec_probe, .remove = dw_hdmi_cec_remove, .driver = { .name ="dw-hdmi-cec" , + .pm = &dw_hdmi_cec_pm, },Quoted 7 lines
Quoted 2 lines
}; module_platform_driver(dw_hdmi_cec_driver);As Hans said on v1, why don't you call
dw_hdmi_cec_enable(cec->adap, false)in suspend anddw_hdmi_cec_enable(cec->adap, true)in resume ?With this, CEC engine is not disabled on suspend.
This should not be done, at least not unconditionally. CEC wakeup functionality is used by Crust firmware for Allwinner boards. In fact, DW HDMI CEC controller was designed with suspend/resume functionality in mind. If properly set, it can autonomously scan for preset CEC messages and generate interrupt when found.
Quoted 4 lines
Actually, I'm not fan of this patch, since it looks like workaround for power management firmware not restoring previous state. Or is this HW issue? In any case, Allwinner SoCs with DW-HDMI CEC don't need restoring any register, so it's certainly not a general issue.
In this case I think it should explicit in the hdmi_plat_data to either let CEC enabled on suspend or then disable CEC on suspend.
Quoted 6 lines
Quoted 3 lines
Do you plan to use the engine from the suspend code ?
As mentioned before, it's already done for Allwinner, so CEC should remain enabled
Thanks for confirming that
Quoted 10 lines
Best regards,
JernejQuoted 2 lines
Neil
Neil
RE: [EXT] Re: [PATCH v2 1/5] drm: bridge: dw_hdmi: cec: Add cec suspend/resume function
In reply to Jernej ŠkrabecQuoted 118 lines
-----Original Message-----
From: Jernej Škrabec <[email protected]>
Sent: 2022年4月10日 18:13
To: Sandor Yu <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Neil Armstrong <[email protected]>
Cc: S.J. Wang <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v2 1/5] drm: bridge:dw_hdmi: cec: Add cec suspend/resume functionCaution: EXT Email
Dne petek, 08. april 2022 ob 15:41:36 CEST je Neil Armstrong napisal(a):
Quoted 11 lines · Sandor Yu
Quoted 10 lines
CEC interrupt status/mask and logical address registers will be reset when device enter suspend.
It will cause cec fail to work after device resume.
Add CEC suspend/resume functions, reinitialize logical address registers and restore interrupt status/mask registers after resume.Signed-off-by Sandor Yu <[email protected]>---
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 37+++++++++++++++++++
Quoted 51 lines
Quoted 51 lines
1 file changed, 37 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.cindexc8f44bcb298a..ab176401b727100644drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +4
-0@@ -62,6 +62,10 @@ struct dw_hdmi_cec {bool rx_done;struct cec_notifier *notify;int irq; + +u8 regs_polarity; +u8 regs_mask; +u8 regs_mute_stat0;};static void dw_hdmi_write(struct
dw_hdmi_cec*cec, u8 val, int
offset)drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +0
-0@@ -306,11 +310,44 @@ static int dw_hdmi_cec_remove(struct
platform_device*pdev)>return 0;}drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +22
-0+static int __maybe_unused dw_hdmi_cec_resume (struct device *dev) { +struct dw_hdmi_cec *cec =dev_get_drvdata (dev); + +/* Restore logical address */ +dw_hdmi_write (cec, cec->addresses &255 ,HDMI_CEC_ADDR_L ); +dw_hdmi_write (cec, cec->addresses >>8 ,HDMI_CEC_ADDR_H ); + +/* Restore interrupt status/mask register */ +dw_hdmi_write (cec, cec->regs_polarity,HDMI_CEC_POLARITY ); +dw_hdmi_write (cec, cec->regs_mask,HDMI_CEC_MASK ); +dw_hdmi_write (cec, cec->regs_mute_stat0, +HDMI_IH_MUTE_CEC_STAT0 ); + +return 0 ; +} + +static int __maybe_unused dw_hdmi_cec_suspend (struct device *dev) { +struct dw_hdmi_cec *cec =dev_get_drvdata (dev); + +/* store interrupt status/mask register */ + cec->regs_polarity =dw_hdmi_read (cec,HDMI_CEC_POLARITY ); + cec->regs_mask =dw_hdmi_read (cec,HDMI_CEC_MASK );Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c static int dw_hdmi_cec_remove(struct platform_device *pdev)
Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +8
-0+ cec->regs_mute_stat0 =dw_hdmi_read (cec, +HDMI_IH_MUTE_CEC_STAT0 ); + +return 0 ; +} + +static const struct dev_pm_ops dw_hdmi_cec_pm = { + SET_SYSTEM_SLEEP_PM_OPS(dw_hdmi_cec_suspend,
dw_hdmi_cec_resume)Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +3
-0+}; +static struct platform_driver dw_hdmi_cec_driver = { .probe = dw_hdmi_cec_probe, .remove = dw_hdmi_cec_remove, .driver = { .name ="dw-hdmi-cec" , + .pm = &dw_hdmi_cec_pm, },Quoted 7 lines
Quoted 2 lines
}; module_platform_driver(dw_hdmi_cec_driver);As Hans said on v1, why don't you call
dw_hdmi_cec_enable(cec->adap, false)in suspend anddw_hdmi_cec_enable(cec->adap, true)in resume ?With this, CEC engine is not disabled on suspend.
This should not be done, at least not unconditionally. CEC wakeup functionality is used by Crust firmware for Allwinner boards. In fact, DW HDMI CEC controller was designed with suspend/resume functionality in mind. If properly set, it can autonomously scan for preset CEC messages and generate interrupt when found.
Quoted 5 lines
Actually, I'm not fan of this patch, since it looks like workaround for power management firmware not restoring previous state. Or is this HW issue? In any case, Allwinner SoCs with DW-HDMI CEC don't need restoring any register, so it's certainly not a general issue.
For NXP i.MX8MPlus SOC, CEC wakeup function is not required.
And the HDMI TX power domain could be gated off with CEC engine when suspend.
Restore those registers in order to keep EARC/ARC in working after resume when HDMI TX power domain off in suspend. It could be use by other SOC for extremely low power case.
B.R
Sandor
Quoted 15 lines
Quoted 3 lines
Do you plan to use the engine from the suspend code ?
As mentioned before, it's already done for Allwinner, so CEC should remain enabled.
Best regards,
JernejQuoted 2 lines
Neil
PATCH v2 2/5 drm: bridge: dw_hdmi: default enable workaround to clear the overflow
In reply to Sandor Yui.MX8MPlus (v2.13a) has verified need the workaround to clear the overflow with one iteration.
Only i.MX6Q(v1.30a) need the workaround with 4 iterations, the others versions later than v1.3a have been identified as needing the workaround with a single iteration.
Default enable the workaround with one iteration for all versions later than v1.30a.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +7 -16
@@ -2086,30 +2086,21 @@ static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi)* then write one of the FC registers several times. * * The number of iterations matters and depends on the HDMI TX revision -* (and possibly on the platform). So far i.MX6Q (v1.30a), i.MX6DL -* (v1.31a) and multiple Allwinner SoCs (v1.32a) have been identified -* as needing the workaround, with 4 iterations for v1.30a and 1 -* iteration for others. -* The Amlogic Meson GX SoCs (v2.01a) have been identified as needing -* the workaround with a single iteration. -* The Rockchip RK3288 SoC (v2.00a) and RK3328/RK3399 SoCs (v2.11a) have -* been identified as needing the workaround with a single iteration. +* (and possibly on the platform). +* 4 iterations for i.MX6Q(v1.30a) and 1 iteration for others. +* i.MX6DL (v1.31a), Allwinner SoCs (v1.32a), Rockchip RK3288 SoC (v2.00a), +* Amlogic Meson GX SoCs (v2.01a), RK3328/RK3399 SoCs (v2.11a) +* and i.MX8MPlus (v2.13a) have been identified as needing the workaround +* with a single iteration. */ switch (hdmi->version) {case 0x130a : count =4 ;break ; -case 0x131a : -case 0x132a : -case 0x200a : -case 0x201a : -case 0x211a : -case 0x212a : +default : count =1 ;break ; -default : -return ; }/* TMDS software reset */
Signature · 1 line
2.25.1
Re: [PATCH v2 2/5] drm: bridge: dw_hdmi: default enable workaround to clear the overflow
Quoted 46 lines · Sandor Yu
i.MX8MPlus (v2.13a) has verified need the workaround to clear the overflow with one iteration.
Onlyi.MX6Q(v1.30a)need the workaround with 4 iterations, the others versions later than v1.3a have been identified as needing the workaround with a single iteration.Default enable the workaround with one iteration for all versions later than v1.30a.
Signed-off-by Sandor Yu <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +6
-12@@ -2086,30 +2086,21 @@ static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi)* then write one of the FC registers several times. * * The number of iterations matters and depends on the HDMI TX revision -* (and possibly on the platform). So far i.MX6Q (v1.30a), i.MX6DL -* (v1.31a) and multiple Allwinner SoCs (v1.32a) have been identified -* as needing the workaround, with 4 iterations for v1.30a and 1 -* iteration for others. -* The Amlogic Meson GX SoCs (v2.01a) have been identified as needing -* the workaround with a single iteration. -* The Rockchip RK3288 SoC (v2.00a) and RK3328/RK3399 SoCs (v2.11a) have -* been identified as needing the workaround with a single iteration. +* (and possibly on the platform). +* 4 iterations for i.MX6Q(v1.30a) and 1 iteration for others. +* i.MX6DL (v1.31a), Allwinner SoCs (v1.32a), Rockchip RK3288 SoC (v2.00a), +* Amlogic Meson GX SoCs (v2.01a), RK3328/RK3399 SoCs (v2.11a) +* and i.MX8MPlus (v2.13a) have been identified as needing the workaround +* with a single iteration. */ switch (hdmi->version) {case 0x130a : count =4 ;break ; -case 0x131a : -case 0x132a : -case 0x200a : -case 0x201a :
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi) · line 2106
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1
-4-case 0x211a : -case 0x212a : +default : count =1 ;break ; -default : -return ; }/* TMDS software reset */
Jernej Škrabec
maintainerRe: [PATCH v2 2/5] drm: bridge: dw_hdmi: default enable workaround to clear the overflow
In reply to Sandor YuDne petek, 08. april 2022 ob 12:32:25 CEST je Sandor Yu napisal(a):
Quoted 20 lines
i.MX8MPlus (v2.13a) has verified need the workaround to clear the overflow with one iteration.
Onlyi.MX6Q(v1.30a)need the workaround with 4 iterations, the others versions later than v1.3a have been identified as needing the workaround with a single iteration.Default enable the workaround with one iteration for all versions later than v1.30a.
Signed-off-by Sandor Yu <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.cindex4befc104d220..02d8f7e08814100644
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void dw_hdmi_clear_overflow(struct dw_hdmi · line 2088
Quoted 3 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-0@@ -2086,30 +2086,21 @@ static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi) * then write one of the FC registers several times. * * The number of iterations matters and depends on the HDMI TX
revision
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void dw_hdmi_clear_overflow(struct dw_hdmi · line 2090
Quoted 2 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-2-* (and possibly on the platform). So far i.MX6Q (v1.30a), i.MX6DL -* (v1.31a) and multiple Allwinner SoCs (v1.32a) have been
identified
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi)
Quoted 3 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-3-* as needing the workaround, with 4 iterations for v1.30a and 1 -* iteration for others. -* The Amlogic Meson GX SoCs (v2.01a) have been identified as
needing
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void dw_hdmi_clear_overflow(struct dw_hdmi · line 2095
Quoted 2 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-2-* the workaround with a single iteration. -* The Rockchip RK3288 SoC (v2.00a) and RK3328/RK3399 SoCs
(v2.11a) have
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void dw_hdmi_clear_overflow(struct dw_hdmi · line 2096
Quoted 1 line
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-1-* been identified as needing the workaround with a single
iteration.
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void dw_hdmi_clear_overflow(struct dw_hdmi · line 2093
Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4
-0+* (and possibly on the platform). +* 4 iterations for i.MX6Q(v1.30a) and 1 iteration for others. +* i.MX6DL (v1.31a), Allwinner SoCs (v1.32a), Rockchip RK3288 SoC (v2.00a), + * Amlogic Meson GX SoCs (v2.01a), RK3328/RK3399 SoCs (v2.11a) +* and i.MX8MPlus (v2.13a) have been identified as needing the
workaround
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi) · line 2095
Quoted 2 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1
-0+* with a single iteration. */
It would be easier to read and modify later if platforms/controllers/variants are given as list, one per line, but it could be done later.
Best regards,
Jernej
Quoted 19 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1
-8switch (hdmi->version) {case 0x130a : count =4 ;break ; -case 0x131a : -case 0x132a : -case 0x200a : -case 0x201a : -case 0x211a : -case 0x212a : +default : count =1 ;break ; -default : -return ; }/* TMDS software reset */
PATCH v2 3/5 drm: bridge: dw_hdmi: Enable GCP only for Deep Color
In reply to Sandor YuHDMI1.4b specification section 6.5.3:
Source shall only send GCPs with non-zero CD to sinks that indicate support for Deep Color.
DW HDMI GCP default enabled, clear gpc_auto bit for 24-bit color depth.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +12 -0
@@ -1108,6 +1108,8 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi)unsigned int output_select =HDMI_VP_CONF_OUTPUT_SELECTOR_PP ;struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data;u8 val, vp_conf; +u8 clear_gcp_auto =0 ; + if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format) || hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format) ||
@@ -1117,6 +1119,7 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi)case 8 : color_depth =4 ; output_select =HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS ; + clear_gcp_auto =1 ;break ;case 10 : color_depth =5 ;
@@ -1136,6 +1139,7 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi)case 0 :case 8 : remap_size = HDMI_VP_REMAP_YCC422_16bit; + clear_gcp_auto =1 ;break ;case 10 : remap_size = HDMI_VP_REMAP_YCC422_20bit;
@@ -1160,6 +1164,14 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi) HDMI_VP_PR_CD_DESIRED_PR_FACTOR_MASK);hdmi_writeb (hdmi, val,HDMI_VP_PR_CD ); + val =hdmi_readb (hdmi,HDMI_FC_DATAUTO3 ); +if (clear_gcp_auto ==1 ) +/* disable Auto GCP when 24-bit color */ + val &= ~0x4 ; +else + val |=0x4 ; +hdmi_writeb (hdmi, val,HDMI_FC_DATAUTO3 ); +hdmi_modb (hdmi,HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE ,HDMI_VP_STUFF_PR_STUFFING_MASK ,HDMI_VP_STUFF );
Signature · 1 line
2.25.1
Re: [PATCH v2 3/5] drm: bridge: dw_hdmi: Enable GCP only for Deep Color
Quoted 5 lines · Sandor Yu
HDMI1.4b specification section 6.5.3:
Source shall only send GCPs with non-zero CD to sinks that indicate support for Deep Color.DW HDMI GCP default enabled, clear
gpc_autobit for 24-bit color depth.
It's right because we do not handle AVMUTE, Pixel Packing nor Default_Phase.
Quoted 36 lines
Signed-off-by Sandor Yu <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4
-0@@ -1108,6 +1108,8 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi)unsigned int output_select =HDMI_VP_CONF_OUTPUT_SELECTOR_PP ;struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data;u8 val, vp_conf; +u8 clear_gcp_auto =0 ; + if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format) || hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format) ||@@ -1117,6 +1119,7 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi)case 8 : color_depth =4 ; output_select =HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS ; + clear_gcp_auto =1 ;break ;case 10 : color_depth =5 ;@@ -1136,6 +1139,7 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi)case 0 :case 8 : remap_size = HDMI_VP_REMAP_YCC422_16bit; + clear_gcp_auto =1 ;break ;case 10 : remap_size = HDMI_VP_REMAP_YCC422_20bit;
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_video_packetize(struct dw_hdmi *hdmi) · line 1169
Quoted 6 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +3
-0@@ -1160,6 +1164,14 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi) HDMI_VP_PR_CD_DESIRED_PR_FACTOR_MASK);hdmi_writeb (hdmi, val,HDMI_VP_PR_CD ); + val =hdmi_readb (hdmi,HDMI_FC_DATAUTO3 ); +if (clear_gcp_auto ==1 ) +/* disable Auto GCP when 24-bit color */
Maybe add a new define for HDMI_FC_DATAUTO3_GCP_AUTO bit and use it here.
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_video_packetize(struct dw_hdmi *hdmi) · line 1173
Quoted 4 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4
-0+ val &= ~0x4 ; + else + val |= 0x4; +hdmi_writeb (hdmi, val,HDMI_FC_DATAUTO3 );
Please also add a comment explaining we clear GCP because we only transmit CD and do not handle AVMUTE, PP nor Default_Phase (yet).
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_video_packetize(struct dw_hdmi *hdmi) · line 1177
Quoted 4 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1
-0+hdmi_modb (hdmi,HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE ,HDMI_VP_STUFF_PR_STUFFING_MASK ,HDMI_VP_STUFF );
Thanks,
Neil
RE: [EXT] Re: [PATCH v2 3/5] drm: bridge: dw_hdmi: Enable GCP only for Deep Color
Quoted 75 lines
-----Original Message-----
From: Neil Armstrong <[email protected]>
Sent: 2022年4月8日 20:40
To: Sandor Yu <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: S.J. Wang <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v2 3/5] drm: bridge:dw_hdmi: Enable GCP only for Deep ColorCaution: EXT Email
Quoted 5 lines · Sandor Yu
HDMI1.4b specification section 6.5.3:
Source shall only send GCPs with non-zero CD to sinks that indicate support for Deep Color.DW HDMI GCP default enabled, clear
gpc_autobit for 24-bit color depth.It's right because we do not handle AVMUTE, Pixel Packing nor
Default_Phase.drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_video_packetize(struct
Quoted 12 lines
Signed-off-by Sandor Yu <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-0@@ -1108,6 +1108,8 @@ static void hdmi_video_packetize(struct
dw_hdmi*hdmi)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_video_packetize(struct · line 1108
Quoted 1 line
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-0unsigned int output_select =
HDMI_VP_CONF_OUTPUT_SELECTOR_PP;drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_video_packetize(struct dw_hdmi *hdmi)
Quoted 7 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-0struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data;u8 val, vp_conf; +u8 clear_gcp_auto =0 ; + if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format) ||
hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format)Quoted 1 line
|| @@ -1117,6 +1119,7 @@ static void hdmi_video_packetize(struct
dw_hdmi*hdmi)Quoted 8 lines
case 8: color_depth = 4; output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; + clear_gcp_auto = 1; break; case 10: color_depth = 5; @@ -1136,6 +1139,7 @@static
Quoted 4 lines
void
hdmi_video_packetize(struct dw_hdmi *hdmi)case 0: case 8: remap_size =
HDMI_VP_REMAP_YCC422_16bit;Quoted 4 lines
+ clear_gcp_auto = 1; break; case 10: remap_size = HDMI_VP_REMAP_YCC422_20bit;@@
Quoted 1 line
-1160,6 +1164,14 @@ static void hdmi_video_packetize(struct
dw_hdmi*hdmi)
Quoted 3 lines
HDMI_VP_PR_CD_DESIRED_PR_FACTOR_MASK); hdmi_writeb(hdmi, val, HDMI_VP_PR_CD);
Quoted 6 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_video_packetize(struct dw_hdmi *hdmi) · line 1169
Quoted 3 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +3
-0+ val =hdmi_readb (hdmi,HDMI_FC_DATAUTO3 ); +if (clear_gcp_auto ==1 ) +/* disable Auto GCP when 24-bit color */ Maybe add a new define for
HDMI_FC_DATAUTO3_GCP_AUTObit and use it here.
OK, I will add it.
Quoted 9 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_video_packetize(struct dw_hdmi *hdmi) · line 1173
Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4
-0+ val &= ~0x4 ; + else + val |= 0x4; +hdmi_writeb (hdmi, val,HDMI_FC_DATAUTO3 );Please also add a comment explaining we clear GCP because we only transmit CD and do not handle AVMUTE, PP nor
Default_Phase(yet).
OK.
Sandor
Quoted 9 lines
Quoted 2 lines
+
hdmi_modb(hdmi,
HDMI_VP_STUFF_PR_STUFFING_STUFFING_MODE,Quoted 1 line
HDMI_VP_STUFF_PR_STUFFING_MASK,
HDMI_VP_STUFF);Quoted 1 line
Thanks,
Neil
PATCH v2 4/5 drm: bridge: dw_hdmi: add reset function for PHY GEN1
In reply to Sandor YuPHY reset register(MC_PHYRSTZ) active high reset control for PHY GEN2, and active low reset control for PHY GEN1.
Rename function dw_hdmi_phy_reset to dw_hdmi_phy_gen2_reset. Add dw_hdmi_phy_gen1_reset function for PHY GEN1.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 14 +++++++++++--- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 2 +- include/drm/bridge/dw_hdmi.h | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +11 -3
@@ -1369,13 +1369,21 @@ static void dw_hdmi_phy_sel_interface_control(struct dw_hdmi *hdmi, u8 enable) HDMI_PHY_CONF0_SELDIPIF_MASK); } -void dw_hdmi_phy_reset (struct dw_hdmi *hdmi) +void dw_hdmi_phy_gen1_reset (struct dw_hdmi *hdmi) +{ +/* PHY reset. The reset signal is active low on Gen1 PHYs. */ +hdmi_writeb (hdmi,0 ,HDMI_MC_PHYRSTZ ); +hdmi_writeb (hdmi,HDMI_MC_PHYRSTZ_PHYRSTZ ,HDMI_MC_PHYRSTZ ); +} +EXPORT_SYMBOL_GPL (dw_hdmi_phy_gen1_reset); + +void dw_hdmi_phy_gen2_reset (struct dw_hdmi *hdmi) {/* PHY reset. The reset signal is active high on Gen2 PHYs. */ hdmi_writeb (hdmi,HDMI_MC_PHYRSTZ_PHYRSTZ ,HDMI_MC_PHYRSTZ );hdmi_writeb (hdmi,0 ,HDMI_MC_PHYRSTZ ); } -EXPORT_SYMBOL_GPL (dw_hdmi_phy_reset); +EXPORT_SYMBOL_GPL (dw_hdmi_phy_gen2_reset);void dw_hdmi_phy_i2c_set_addr (struct dw_hdmi *hdmi,u8 address) {
@@ -1529,7 +1537,7 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi,if (phy->has_svsret)dw_hdmi_phy_enable_svsret (hdmi,1 ); -dw_hdmi_phy_reset (hdmi); +dw_hdmi_phy_gen2_reset (hdmi);hdmi_writeb (hdmi,HDMI_MC_HEACPHY_RST_ASSERT ,HDMI_MC_HEACPHY_RST );
drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +1 -1
@@ -135,7 +135,7 @@ static int sun8i_hdmi_phy_config_a83t(struct dw_hdmi *hdmi,dw_hdmi_phy_gen2_txpwron (hdmi,0 );dw_hdmi_phy_gen2_pddq (hdmi,1 ); -dw_hdmi_phy_reset (hdmi); +dw_hdmi_phy_gen2_reset (hdmi);dw_hdmi_phy_gen2_pddq (hdmi,0 );
include/drm/bridge/dw_hdmi.h +3 -1
@@ -187,9 +187,11 @@ void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi, u8 address);void dw_hdmi_phy_i2c_write (struct dw_hdmi *hdmi,unsigned short data,unsigned char addr); +void dw_hdmi_phy_gen1_reset (struct dw_hdmi *hdmi); +void dw_hdmi_phy_gen2_pddq (struct dw_hdmi *hdmi,u8 enable);void dw_hdmi_phy_gen2_txpwron (struct dw_hdmi *hdmi,u8 enable); -void dw_hdmi_phy_reset (struct dw_hdmi *hdmi); +void dw_hdmi_phy_gen2_reset (struct dw_hdmi *hdmi);enum drm_connector_status dw_hdmi_phy_read_hpd (struct dw_hdmi *hdmi,void *data);
Signature · 1 line
2.25.1
Re: [PATCH v2 4/5] drm: bridge: dw_hdmi: add reset function for PHY GEN1
Quoted 70 lines · Sandor Yu
PHY reset
register(MC_PHYRSTZ)active high reset control for PHY GEN2, and active low reset control for PHY GEN1.Rename function
dw_hdmi_phy_resettodw_hdmi_phy_gen2_reset. Adddw_hdmi_phy_gen1_resetfunction for PHY GEN1.Signed-off-by Sandor Yu <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 14 +++++++++++--- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 2 +- include/drm/bridge/dw_hdmi.h | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +11
-3@@ -1369,13 +1369,21 @@ static void dw_hdmi_phy_sel_interface_control(struct dw_hdmi *hdmi, u8 enable) HDMI_PHY_CONF0_SELDIPIF_MASK); } -void dw_hdmi_phy_reset (struct dw_hdmi *hdmi) +void dw_hdmi_phy_gen1_reset (struct dw_hdmi *hdmi) +{ +/* PHY reset. The reset signal is active low on Gen1 PHYs. */ +hdmi_writeb (hdmi,0 ,HDMI_MC_PHYRSTZ ); +hdmi_writeb (hdmi,HDMI_MC_PHYRSTZ_PHYRSTZ ,HDMI_MC_PHYRSTZ ); +} +EXPORT_SYMBOL_GPL (dw_hdmi_phy_gen1_reset); + +void dw_hdmi_phy_gen2_reset (struct dw_hdmi *hdmi) {/* PHY reset. The reset signal is active high on Gen2 PHYs. */ hdmi_writeb (hdmi,HDMI_MC_PHYRSTZ_PHYRSTZ ,HDMI_MC_PHYRSTZ );hdmi_writeb (hdmi,0 ,HDMI_MC_PHYRSTZ ); } -EXPORT_SYMBOL_GPL (dw_hdmi_phy_reset); +EXPORT_SYMBOL_GPL (dw_hdmi_phy_gen2_reset);void dw_hdmi_phy_i2c_set_addr (struct dw_hdmi *hdmi,u8 address) {@@ -1529,7 +1537,7 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi,if (phy->has_svsret)dw_hdmi_phy_enable_svsret (hdmi,1 ); -dw_hdmi_phy_reset (hdmi); +dw_hdmi_phy_gen2_reset (hdmi);hdmi_writeb (hdmi,HDMI_MC_HEACPHY_RST_ASSERT ,HDMI_MC_HEACPHY_RST );drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +1
-1@@ -135,7 +135,7 @@ static int sun8i_hdmi_phy_config_a83t(struct dw_hdmi *hdmi,dw_hdmi_phy_gen2_txpwron (hdmi,0 );dw_hdmi_phy_gen2_pddq (hdmi,1 ); -dw_hdmi_phy_reset (hdmi); +dw_hdmi_phy_gen2_reset (hdmi);dw_hdmi_phy_gen2_pddq (hdmi,0 );include/drm/bridge/dw_hdmi.h +0
-0@@ -187,9 +187,11 @@ void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi, u8 address);void dw_hdmi_phy_i2c_write (struct dw_hdmi *hdmi,unsigned short data,unsigned char addr);
include/drm/bridge/dw_hdmi.h void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi, u8 address); · line 197
Quoted 10 lines
include/drm/bridge/dw_hdmi.h +3
-1+void dw_hdmi_phy_gen1_reset (struct dw_hdmi *hdmi); +void dw_hdmi_phy_gen2_pddq (struct dw_hdmi *hdmi,u8 enable);void dw_hdmi_phy_gen2_txpwron (struct dw_hdmi *hdmi,u8 enable); -void dw_hdmi_phy_reset (struct dw_hdmi *hdmi); +void dw_hdmi_phy_gen2_reset (struct dw_hdmi *hdmi);enum drm_connector_status dw_hdmi_phy_read_hpd (struct dw_hdmi *hdmi,void *data);
If a sun4i drm maintainer can ack, then it would be all good to apply.
Neil
Re: [PATCH v2 4/5] drm: bridge: dw_hdmi: add reset function for PHY GEN1
Dne petek, 08. april 2022 ob 14:22:52 CEST je Neil Armstrong napisal(a):
Quoted 53 lines · Sandor Yu
Quoted 52 lines
PHY reset
register(MC_PHYRSTZ)active high reset control for PHY GEN2, and active low reset control for PHY GEN1.Rename function
dw_hdmi_phy_resettodw_hdmi_phy_gen2_reset. Adddw_hdmi_phy_gen1_resetfunction for PHY GEN1.Signed-off-by Sandor Yu <[email protected]>---
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 14 +++++++++++--- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 2 +- include/drm/bridge/dw_hdmi.h | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.cindex5a7ec066e37a..13270d96e5be100644drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-0@@ -1369,13 +1369,21 @@ static void
dw_hdmi_phy_sel_interface_control(struct dw_hdmi *hdmi, u8 enable)>
HDMI_PHY_CONF0_SELDIPIF_MASK);}drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +10
-2-void dw_hdmi_phy_reset (struct dw_hdmi *hdmi) +void dw_hdmi_phy_gen1_reset (struct dw_hdmi *hdmi) +{ +/* PHY reset. The reset signal is active low on Gen1 PHYs. */ +hdmi_writeb (hdmi,0 ,HDMI_MC_PHYRSTZ ); +hdmi_writeb (hdmi,HDMI_MC_PHYRSTZ_PHYRSTZ ,HDMI_MC_PHYRSTZ ); +} +EXPORT_SYMBOL_GPL (dw_hdmi_phy_gen1_reset); + +void dw_hdmi_phy_gen2_reset (struct dw_hdmi *hdmi) {/* PHY reset. The reset signal is active high on Gen2 PHYs. */ hdmi_writeb (hdmi,HDMI_MC_PHYRSTZ_PHYRSTZ ,HDMI_MC_PHYRSTZ );hdmi_writeb (hdmi,0 ,HDMI_MC_PHYRSTZ ); } -EXPORT_SYMBOL_GPL (dw_hdmi_phy_reset); +EXPORT_SYMBOL_GPL (dw_hdmi_phy_gen2_reset);void dw_hdmi_phy_i2c_set_addr (struct dw_hdmi *hdmi,u8 address) {@@ -1529,7 +1537,7 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi,
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1
-1if (phy->has_svsret)dw_hdmi_phy_enable_svsret (hdmi,1 ); -dw_hdmi_phy_reset (hdmi); +dw_hdmi_phy_gen2_reset (hdmi);hdmi_writeb(hdmi,
HDMI_MC_HEACPHY_RST_ASSERT,
HDMI_MC_HEACPHY_RST);
Quoted 32 lines
Quoted 32 lines
(quoted diff) +0
-0
b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.cindex5e2b0175df36..2860e6bff8b7100644drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +1
-1@@ -135,7 +135,7 @@ static int sun8i_hdmi_phy_config_a83t(struct dw_hdmi *hdmi,>dw_hdmi_phy_gen2_txpwron (hdmi,0 );dw_hdmi_phy_gen2_pddq (hdmi,1 ); -dw_hdmi_phy_reset (hdmi); +dw_hdmi_phy_gen2_reset (hdmi);dw_hdmi_phy_gen2_pddq (hdmi,0 );include/drm/bridge/dw_hdmi.h +0
-0@@ -187,9 +187,11 @@ void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi,u8 address);>
void dw_hdmi_phy_i2c_write(structdw_hdmi*hdmi, unsigned short data,unsigned char addr);
include/drm/bridge/dw_hdmi.h +2
-0+void dw_hdmi_phy_gen1_reset (struct dw_hdmi *hdmi); +void dw_hdmi_phy_gen2_pddq (struct dw_hdmi *hdmi,u8 enable);void dw_hdmi_phy_gen2_txpwron (struct dw_hdmi *hdmi,u8 enable);
Quoted 8 lines
include/drm/bridge/dw_hdmi.h void dw_hdmi_phy_i2c_set_addr(struct dw_hdmi *hdmi, u8 address); · line 197
Quoted 6 lines
include/drm/bridge/dw_hdmi.h +1
-1-void dw_hdmi_phy_reset (struct dw_hdmi *hdmi); +void dw_hdmi_phy_gen2_reset (struct dw_hdmi *hdmi);enum drm_connector_status dw_hdmi_phy_read_hpd (struct dw_hdmi *hdmi,void *data);Reviewed-by Neil Armstrong <[email protected]>
Best regards,
Jernej
Quoted 4 lines
If a sun4i drm maintainer can ack, then it would be all good to apply.
Neil
PATCH v2 5/5 drm: bridge: dw_hdmi: Audio: Add General Parallel Audio (GPA) driver
In reply to Sandor YuGeneral Parallel Audio (GPA) interface is one of the supported audio interface for synopsys HDMI module, which has verified for i.MX8MPlus platform.
This is initial version for GPA.
--- drivers/gpu/drm/bridge/synopsys/Kconfig | 10 + drivers/gpu/drm/bridge/synopsys/Makefile | 1 + .../drm/bridge/synopsys/dw-hdmi-gp-audio.c | 199 ++++++++++++++++++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 128 ++++++++++- drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 13 +- include/drm/bridge/dw_hdmi.h | 5 + 6 files changed, 353 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c
drivers/gpu/drm/bridge/synopsys/Kconfig +10 -0
@@ -25,6 +25,16 @@ config DRM_DW_HDMI_I2S_AUDIO Support the I2S Audio interface which is part of the Synopsys Designware HDMI block. +config DRM_DW_HDMI_GP_AUDIO + tristate "Synopsys Designware GP Audio interface" + depends on DRM_DW_HDMI && SND + select SND_PCM + select SND_PCM_ELD + select SND_PCM_IEC958 + help + Support the GP Audio interface which is part of the Synopsys + Designware HDMI block. + config DRM_DW_HDMI_CEC tristate "Synopsis Designware CEC interface" depends on DRM_DW_HDMI
drivers/gpu/drm/bridge/synopsys/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o +obj-$(CONFIG_DRM_DW_HDMI_GP_AUDIO) += dw-hdmi-gp-audio.o obj-$(CONFIG_DRM_DW_HDMI_I2S_AUDIO) += dw-hdmi-i2s-audio.o obj-$(CONFIG_DRM_DW_HDMI_CEC) += dw-hdmi-cec.o
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +199 -0
199 lines not on this page · raw message
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +127 -1
189 lines not on this page · raw message
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +11 -2
@@ -158,8 +158,17 @@#define HDMI_FC_SPDDEVICEINF 0x1062#define HDMI_FC_AUDSCONF 0x1063#define HDMI_FC_AUDSSTAT 0x1064 -#define HDMI_FC_AUDSCHNLS7 0x106e -#define HDMI_FC_AUDSCHNLS8 0x106f +#define HDMI_FC_AUDSV 0x1065 +#define HDMI_FC_AUDSU 0x1066 +#define HDMI_FC_AUDSCHNLS0 0x1067 +#define HDMI_FC_AUDSCHNLS1 0x1068 +#define HDMI_FC_AUDSCHNLS2 0x1069 +#define HDMI_FC_AUDSCHNLS3 0x106A +#define HDMI_FC_AUDSCHNLS4 0x106B +#define HDMI_FC_AUDSCHNLS5 0x106C +#define HDMI_FC_AUDSCHNLS6 0x106D +#define HDMI_FC_AUDSCHNLS7 0x106E +#define HDMI_FC_AUDSCHNLS8 0x106F#define HDMI_FC_DATACH0FILL 0x1070#define HDMI_FC_DATACH1FILL 0x1071#define HDMI_FC_DATACH2FILL 0x1072
include/drm/bridge/dw_hdmi.h +5 -0
@@ -121,6 +121,9 @@ struct dw_hdmi_phy_ops {void (*update_hpd)(struct dw_hdmi *hdmi,void *data,bool force,bool disabled,bool rxsense);void (*setup_hpd)(struct dw_hdmi *hdmi,void *data); +void (*enable_audio)(struct dw_hdmi *hdmi,void *data,int channel, +int width,int rate,int non_pcm); +void (*disable_audio)(struct dw_hdmi *hdmi,void *data); };struct dw_hdmi_plat_data {
@@ -173,6 +176,8 @@ void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense);int dw_hdmi_set_plugged_cb (struct dw_hdmi *hdmi,hdmi_codec_plugged_cb fn,struct device *codec_dev); +void dw_hdmi_set_sample_non_pcm (struct dw_hdmi *hdmi,unsigned int non_pcm); +void dw_hdmi_set_sample_width (struct dw_hdmi *hdmi,unsigned int width);void dw_hdmi_set_sample_rate (struct dw_hdmi *hdmi,unsigned int rate);void dw_hdmi_set_channel_count (struct dw_hdmi *hdmi,unsigned int cnt);void dw_hdmi_set_channel_status (struct dw_hdmi *hdmi,u8 *channel_status);
Signature · 1 line
2.25.1
Re: [PATCH v2 5/5] drm: bridge: dw_hdmi: Audio: Add General Parallel Audio (GPA) driver
Quoted 243 lines · Sandor Yu
General Parallel Audio (GPA) interface is one of the supported audio interface for synopsys HDMI module, which has verified for i.MX8MPlus platform.
This is initial version for GPA.Signed-off-by Shengjiu Wang <[email protected]>Signed-off-by Sandor Yu <[email protected]>--- drivers/gpu/drm/bridge/synopsys/Kconfig | 10 + drivers/gpu/drm/bridge/synopsys/Makefile | 1 + .../drm/bridge/synopsys/dw-hdmi-gp-audio.c | 199 ++++++++++++++++++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 128 ++++++++++- drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 13 +- include/drm/bridge/dw_hdmi.h | 5 + 6 files changed, 353 insertions(+), 3 deletions(-)create mode 100644
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.cdrivers/gpu/drm/bridge/synopsys/Kconfig +10
-0@@ -25,6 +25,16 @@ config DRM_DW_HDMI_I2S_AUDIO Support the I2S Audio interface which is part of the Synopsys Designware HDMI block. +config DRM_DW_HDMI_GP_AUDIO + tristate "Synopsys Designware GP Audio interface" + depends on DRM_DW_HDMI && SND + select SND_PCM + select SND_PCM_ELD + select SND_PCM_IEC958 + help + Support the GP Audio interface which is part of the Synopsys + Designware HDMI block. + config DRM_DW_HDMI_CEC tristate "Synopsis Designware CEC interface" depends on DRM_DW_HDMIdrivers/gpu/drm/bridge/synopsys/Makefile +1
-0@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o +obj-$(CONFIG_DRM_DW_HDMI_GP_AUDIO) += dw-hdmi-gp-audio.o obj-$(CONFIG_DRM_DW_HDMI_I2S_AUDIO) += dw-hdmi-i2s-audio.o obj-$(CONFIG_DRM_DW_HDMI_CEC) += dw-hdmi-cec.odrivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +187
-0@@ -0,0 +1,199 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* +* dw-hdmi-gp-audio.c +* +* Copyright 2020-2022 NXP +*/ +#include <linux/io.h> +#include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/dmaengine.h> +#include <linux/dma-mapping.h> +#include <drm/bridge/dw_hdmi.h> +#include <drm/drm_edid.h> +#include <drm/drm_connector.h> + +#include <sound/hdmi-codec.h> +#include <sound/asoundef.h> +#include <sound/core.h> +#include <sound/initval.h> +#include <sound/pcm.h> +#include <sound/pcm_drm_eld.h> +#include <sound/pcm_iec958.h> +#include <sound/dmaengine_pcm.h> + +#include "dw-hdmi-audio.h" + +#define DRIVER_NAME "dw-hdmi-gp-audio" +#define DRV_NAME "hdmi-gp-audio" + +struct snd_dw_hdmi { +struct dw_hdmi_audio_data data; +struct platform_device *audio_pdev; +unsigned int pos; +}; + +struct dw_hdmi_channel_conf { +u8 conf1; +u8 ca; +}; + +/* +* The default mapping of ALSA channels to HDMI channels and speaker +* allocation bits. Note that we can't do channel remapping here - +* channels must be in the same order. +* +* Mappings for alsa-lib pcm/surround*.conf files: +* +* Front Sur4.0 Sur4.1 Sur5.0 Sur5.1 Sur7.1 +* Channels 2 4 6 6 6 8 +* +* Our mapping from ALSA channel to CEA686D speaker name and HDMI channel: +* +* Number of ALSA channels +* ALSA Channel 2 3 4 5 6 7 8 +* 0 FL:0 = = = = = = +* 1 FR:1 = = = = = = +* 2 FC:3 RL:4 LFE:2 = = = +* 3 RR:5 RL:4 FC:3 = = +* 4 RR:5 RL:4 = = +* 5 RR:5 = = +* 6 RC:6 = +* 7 RLC/FRC RLC/FRC +*/ +static struct dw_hdmi_channel_conf default_hdmi_channel_config[7 ] = { + {0x03 ,0x00 },/* FL,FR */ + {0x0b ,0x02 },/* FL,FR,FC */ + {0x33 ,0x08 },/* FL,FR,RL,RR */ + {0x37 ,0x09 },/* FL,FR,LFE,RL,RR */ + {0x3f ,0x0b },/* FL,FR,LFE,FC,RL,RR */ + {0x7f ,0x0f },/* FL,FR,LFE,FC,RL,RR,RC */ + {0xff ,0x13 },/* FL,FR,LFE,FC,RL,RR,[FR]RC,[FR]LC */ +}; + +static int audio_hw_params (struct device *dev,void *data, +struct hdmi_codec_daifmt *daifmt, +struct hdmi_codec_params *params) +{ +struct snd_dw_hdmi *dw =dev_get_drvdata (dev); +int ret =0 ; +u8 ca; + +dw_hdmi_set_sample_rate (dw->data.hdmi, params->sample_rate); + + ca = default_hdmi_channel_config[params->channels -2 ].ca; + +dw_hdmi_set_channel_count (dw->data.hdmi, params->channels); +dw_hdmi_set_channel_allocation (dw->data.hdmi, ca); + +dw_hdmi_set_sample_non_pcm (dw->data.hdmi, + params->iec.status[0 ] &IEC958_AES0_NONAUDIO ); +dw_hdmi_set_sample_width (dw->data.hdmi, params->sample_width); + +return ret; +} + +static void audio_shutdown (struct device *dev,void *data) +{ +} + +static int audio_mute_stream (struct device *dev,void *data, +bool enable,int direction) +{ +struct snd_dw_hdmi *dw =dev_get_drvdata (dev); +int ret =0 ; + +if (!enable) +dw_hdmi_audio_enable (dw->data.hdmi); +else +dw_hdmi_audio_disable (dw->data.hdmi); + +return ret; +} + +static int audio_get_eld (struct device *dev,void *data, +u8 *buf,size_t len) +{ +struct dw_hdmi_audio_data *audio = data; +u8 *eld; + + eld = audio->get_eld (audio->hdmi); +if (eld) +memcpy (buf, eld,min_t (size_t,MAX_ELD_BYTES , len)); +else +/* Pass en empty ELD if connector not available */ +memset (buf,0 , len); + +return 0 ; +} + +static int audio_hook_plugged_cb (struct device *dev,void *data, +hdmi_codec_plugged_cb fn, +struct device *codec_dev) +{ +struct snd_dw_hdmi *dw =dev_get_drvdata (dev); + +return dw_hdmi_set_plugged_cb (dw->data.hdmi, fn, codec_dev); +} + +static const struct hdmi_codec_ops audio_codec_ops = { + .hw_params = audio_hw_params, + .audio_shutdown = audio_shutdown, + .mute_stream = audio_mute_stream, + .get_eld = audio_get_eld, + .hook_plugged_cb = audio_hook_plugged_cb, +}; + +static int snd_dw_hdmi_probe (struct platform_device *pdev) +{ +struct dw_hdmi_audio_data *data = pdev->dev.platform_data; +struct snd_dw_hdmi *dw; + +const struct hdmi_codec_pdata codec_data = { + .i2s =1 , + .spdif =0 , + .ops = &audio_codec_ops, + .max_i2s_channels =8 , + .data = data, + }; + + dw =devm_kzalloc (&pdev->dev,sizeof (*dw),GFP_KERNEL ); +if (!dw) +return -ENOMEM ; + + dw->data = *data; + +platform_set_drvdata (pdev, dw); + + dw->audio_pdev =platform_device_register_data (&pdev->dev, +HDMI_CODEC_DRV_NAME ,1 , + &codec_data, +sizeof (codec_data)); + +return PTR_ERR_OR_ZERO (dw->audio_pdev); +} + +static int snd_dw_hdmi_remove (struct platform_device *pdev) +{ +struct snd_dw_hdmi *dw =platform_get_drvdata (pdev); + +platform_device_unregister (dw->audio_pdev); + +return 0 ; +} + +static struct platform_driver snd_dw_hdmi_driver = { + .probe = snd_dw_hdmi_probe,
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c line 197
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +10
-0+ .remove = snd_dw_hdmi_remove, + .driver = { + .name = DRIVER_NAME, + }, +}; + +module_platform_driver (snd_dw_hdmi_driver); + +MODULE_AUTHOR ("Shengjiu Wang <[email protected]>" ); +MODULE_DESCRIPTION ("Synopsis Designware HDMI GPA ALSA interface" );
Should be Synopsys
Quoted 45 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +2
-0+MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:" DRIVER_NAME );drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +9
-0@@ -191,7 +191,10 @@ struct dw_hdmi {spinlock_t audio_lock;struct mutex audio_mutex; +unsigned int sample_non_pcm; +unsigned int sample_width;unsigned int sample_rate; +unsigned int channels;unsigned int audio_cts;unsigned int audio_n;bool audio_enable;@@ -589,6 +592,8 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk) n =4096 ; else if (pixel_clk == 74176000 || pixel_clk == 148352000) n =11648 ; + else if (pixel_clk == 297000000) + n =3072 ; else n =4096 ; n *= mult;@@ -601,6 +606,8 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk) n =17836 ; else if (pixel_clk == 148352000) n =8918 ; + else if (pixel_clk == 297000000) + n =4704 ; else n =6272 ; n *= mult;@@ -615,6 +622,8 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk) n =11648 ; else if (pixel_clk == 148352000) n =5824 ; + else if (pixel_clk == 297000000) + n =5120 ; else n =6144 ; n *= mult;
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi, · line 671
Quoted 3 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-0@@ -660,7 +669,7 @@ static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi, config3 =hdmi_readb (hdmi,HDMI_CONFIG3_ID );/* Only compute CTS when using internal AHB audio */
Please update the comment to include GPAUD as I requested on V1.
Quoted 91 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +69
-1-if (config3 &HDMI_CONFIG3_AHBAUDDMA ) { +if ((config3 &HDMI_CONFIG3_AHBAUDDMA ) || (config3 &HDMI_CONFIG3_GPAUD )) {/* * Compute the CTS value from the N value. Note that CTS and N * can be up to 20 bits in total, so we need 64-bit math. Also @@ -702,6 +711,22 @@ static void hdmi_clk_regenerator_update_pixel_clock(struct dw_hdmi *hdmi)mutex_unlock (&hdmi->audio_mutex); } +void dw_hdmi_set_sample_width (struct dw_hdmi *hdmi,unsigned int width) +{ +mutex_lock (&hdmi->audio_mutex); + hdmi->sample_width = width; +mutex_unlock (&hdmi->audio_mutex); +} +EXPORT_SYMBOL_GPL (dw_hdmi_set_sample_width); + +void dw_hdmi_set_sample_non_pcm (struct dw_hdmi *hdmi,unsigned int non_pcm) +{ +mutex_lock (&hdmi->audio_mutex); + hdmi->sample_non_pcm = non_pcm; +mutex_unlock (&hdmi->audio_mutex); +} +EXPORT_SYMBOL_GPL (dw_hdmi_set_sample_non_pcm); +void dw_hdmi_set_sample_rate (struct dw_hdmi *hdmi,unsigned int rate) {mutex_lock (&hdmi->audio_mutex);@@ -717,6 +742,7 @@ void dw_hdmi_set_channel_count(struct dw_hdmi *hdmi, unsigned int cnt)u8 layout;mutex_lock (&hdmi->audio_mutex); + hdmi->channels = cnt;/* * For >2 channel PCM audio, we need to select layout 1 @@ -765,6 +791,87 @@ static u8 *hdmi_audio_get_eld(struct dw_hdmi *hdmi)return hdmi->curr_conn->eld; } +static void dw_hdmi_gp_audio_enable (struct dw_hdmi *hdmi) +{ +int sample_freq =0x2 , org_sample_freq =0xD ; +int ch_mask =BIT (hdmi->channels) -1 ; + +switch (hdmi->sample_rate) { +case 32000 : + sample_freq =0x03 ; + org_sample_freq =0x0C ; +break ; +case 44100 : + sample_freq =0x00 ; + org_sample_freq =0x0F ; +break ; +case 48000 : + sample_freq =0x02 ; + org_sample_freq =0x0D ; +break ; +case 88200 : + sample_freq =0x08 ; + org_sample_freq =0x07 ; +break ; +case 96000 : + sample_freq =0x0A ; + org_sample_freq =0x05 ; +break ; +case 176400 : + sample_freq =0x0C ; + org_sample_freq =0x03 ; +break ; +case 192000 : + sample_freq =0x0E ; + org_sample_freq =0x01 ; +break ; +default : +break ; + } + +hdmi_set_cts_n (hdmi, hdmi->audio_cts, hdmi->audio_n); +hdmi_enable_audio_clk (hdmi, true); + +hdmi_writeb (hdmi,0x1 ,HDMI_FC_AUDSCHNLS0 ); +hdmi_writeb (hdmi, hdmi->channels,HDMI_FC_AUDSCHNLS2 ); +hdmi_writeb (hdmi,0x22 ,HDMI_FC_AUDSCHNLS3 ); +hdmi_writeb (hdmi,0x22 ,HDMI_FC_AUDSCHNLS4 ); +hdmi_writeb (hdmi,0x11 ,HDMI_FC_AUDSCHNLS5 ); +hdmi_writeb (hdmi,0x11 ,HDMI_FC_AUDSCHNLS6 ); +hdmi_writeb (hdmi, (0x3 <<4 ) | sample_freq,HDMI_FC_AUDSCHNLS7 ); +hdmi_writeb (hdmi, (org_sample_freq <<4 ) |0xb ,HDMI_FC_AUDSCHNLS8 ); + +hdmi_writeb (hdmi, ch_mask,HDMI_GP_CONF1 );
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static u8 *hdmi_audio_get_eld(struct dw_hdmi *hdmi) · line 854
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +10
-0+hdmi_writeb (hdmi,0x02 ,HDMI_GP_CONF2 ); +hdmi_writeb (hdmi,0x01 ,HDMI_GP_CONF0 ); + +hdmi_modb (hdmi,0x3 ,0x3 ,HDMI_FC_DATAUTO3 ); + +/* hbr */ +if (hdmi->sample_rate ==192000 && hdmi->channels ==8 && + hdmi->sample_width ==32 && hdmi->sample_non_pcm) { +hdmi_modb (hdmi,0x01 ,0x01 ,HDMI_GP_CONF2 ); + }
You can drop the brackets here
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static u8 *hdmi_audio_get_eld(struct dw_hdmi *hdmi) · line 861
Quoted 7 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +7
-0+ +if (hdmi->phy.ops->enable_audio) + hdmi->phy.ops->enable_audio (hdmi, hdmi->phy.data, + hdmi->channels, + hdmi->sample_width, + hdmi->sample_rate, + hdmi->sample_non_pcm);
Are this really PHY ops ? or glue ops ? it looks like it's the later.
Those should eventually go in dw_hdmi_plat_data.
Can you elaborate what is done in those callbacks ? can't you use alsa codecs events instead ?
Quoted 96 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +32
-0+} + +static void dw_hdmi_gp_audio_disable (struct dw_hdmi *hdmi) +{ +hdmi_set_cts_n (hdmi, hdmi->audio_cts,0 ); + +hdmi_modb (hdmi,0 ,0x3 ,HDMI_FC_DATAUTO3 ); +if (hdmi->phy.ops->disable_audio) + hdmi->phy.ops->disable_audio (hdmi, hdmi->phy.data); + +hdmi_enable_audio_clk (hdmi, false); +} +static void dw_hdmi_ahb_audio_enable (struct dw_hdmi *hdmi) {hdmi_set_cts_n (hdmi, hdmi->audio_cts, hdmi->audio_n);@@ -3253,6 +3360,7 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, hdmi->plat_data = plat_data; hdmi->dev = dev; hdmi->sample_rate =48000 ; + hdmi->channels =2 ; hdmi->disabled = true; hdmi->rxsense = true; hdmi->phy_mask = (u8 )~(HDMI_PHY_HPD |HDMI_PHY_RX_SENSE );@@ -3476,6 +3584,24 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, pdevinfo.size_data =sizeof (audio); pdevinfo.dma_mask =DMA_BIT_MASK (32 ); hdmi->audio =platform_device_register_full (&pdevinfo); + }else if (iores && config3 &HDMI_CONFIG3_GPAUD ) { +struct dw_hdmi_audio_data audio; + + audio.phys = iores->start; + audio.base = hdmi->regs; + audio.irq = irq; + audio.hdmi = hdmi; + audio.get_eld = hdmi_audio_get_eld; + + hdmi->enable_audio = dw_hdmi_gp_audio_enable; + hdmi->disable_audio = dw_hdmi_gp_audio_disable; + + pdevinfo.name ="dw-hdmi-gp-audio" ; + pdevinfo.id =PLATFORM_DEVID_NONE ; + pdevinfo.data = &audio; + pdevinfo.size_data =sizeof (audio); + pdevinfo.dma_mask =DMA_BIT_MASK (32 ); + hdmi->audio =platform_device_register_full (&pdevinfo); }if (!plat_data->disable_cec && (config0 &HDMI_CONFIG0_CEC )) {drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +11
-2@@ -158,8 +158,17 @@#define HDMI_FC_SPDDEVICEINF 0x1062#define HDMI_FC_AUDSCONF 0x1063#define HDMI_FC_AUDSSTAT 0x1064 -#define HDMI_FC_AUDSCHNLS7 0x106e -#define HDMI_FC_AUDSCHNLS8 0x106f +#define HDMI_FC_AUDSV 0x1065 +#define HDMI_FC_AUDSU 0x1066 +#define HDMI_FC_AUDSCHNLS0 0x1067 +#define HDMI_FC_AUDSCHNLS1 0x1068 +#define HDMI_FC_AUDSCHNLS2 0x1069 +#define HDMI_FC_AUDSCHNLS3 0x106A +#define HDMI_FC_AUDSCHNLS4 0x106B +#define HDMI_FC_AUDSCHNLS5 0x106C +#define HDMI_FC_AUDSCHNLS6 0x106D +#define HDMI_FC_AUDSCHNLS7 0x106E +#define HDMI_FC_AUDSCHNLS8 0x106F#define HDMI_FC_DATACH0FILL 0x1070#define HDMI_FC_DATACH1FILL 0x1071#define HDMI_FC_DATACH2FILL 0x1072include/drm/bridge/dw_hdmi.h +5
-0@@ -121,6 +121,9 @@ struct dw_hdmi_phy_ops {void (*update_hpd)(struct dw_hdmi *hdmi,void *data,bool force,bool disabled,bool rxsense);void (*setup_hpd)(struct dw_hdmi *hdmi,void *data); +void (*enable_audio)(struct dw_hdmi *hdmi,void *data,int channel, +int width,int rate,int non_pcm); +void (*disable_audio)(struct dw_hdmi *hdmi,void *data); };struct dw_hdmi_plat_data {@@ -173,6 +176,8 @@ void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense);int dw_hdmi_set_plugged_cb (struct dw_hdmi *hdmi,hdmi_codec_plugged_cb fn,struct device *codec_dev); +void dw_hdmi_set_sample_non_pcm (struct dw_hdmi *hdmi,unsigned int non_pcm); +void dw_hdmi_set_sample_width (struct dw_hdmi *hdmi,unsigned int width);void dw_hdmi_set_sample_rate (struct dw_hdmi *hdmi,unsigned int rate);void dw_hdmi_set_channel_count (struct dw_hdmi *hdmi,unsigned int cnt);void dw_hdmi_set_channel_status (struct dw_hdmi *hdmi,u8 *channel_status);
RE: [EXT] Re: [PATCH v2 5/5] drm: bridge: dw_hdmi: Audio: Add General Parallel Audio (GPA) driver
Quoted 278 lines
-----Original Message-----
From: Neil Armstrong <[email protected]>
Sent: 2022年4月8日 20:52
To: Sandor Yu <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: S.J. Wang <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v2 5/5] drm: bridge:dw_hdmi: Audio: Add General Parallel Audio (GPA) driverCaution: EXT Email
Quoted 11 lines · Sandor Yu
General Parallel Audio (GPA) interface is one of the supported audio interface for synopsys HDMI module, which has verified for i.MX8MPlus platform.
This is initial version for GPA.Signed-off-by Shengjiu Wang <[email protected]>Signed-off-by Sandor Yu <[email protected]>--- drivers/gpu/drm/bridge/synopsys/Kconfig | 10 + drivers/gpu/drm/bridge/synopsys/Makefile | 1 + .../drm/bridge/synopsys/dw-hdmi-gp-audio.c | 199++++++++++++++++++
Quoted 91 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 128 ++++++++++- drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 13 +- include/drm/bridge/dw_hdmi.h | 5 + 6 files changed, 353 insertions(+), 3 deletions(-)create mode 100644
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.cdrivers/gpu/drm/bridge/synopsys/Kconfig +10
-0@@ -25,6 +25,16 @@ config DRM_DW_HDMI_I2S_AUDIO Support the I2S Audio interface which is part of the Synopsys Designware HDMI block. +config DRM_DW_HDMI_GP_AUDIO + tristate "Synopsys Designware GP Audio interface" + depends on DRM_DW_HDMI && SND + select SND_PCM + select SND_PCM_ELD + select SND_PCM_IEC958 + help + Support the GP Audio interface which is part of the Synopsys + Designware HDMI block. + config DRM_DW_HDMI_CEC tristate "Synopsis Designware CEC interface" depends on DRM_DW_HDMIdrivers/gpu/drm/bridge/synopsys/Makefile +1
-0@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o +obj-$(CONFIG_DRM_DW_HDMI_GP_AUDIO) += dw-hdmi-gp-audio.o obj-$(CONFIG_DRM_DW_HDMI_I2S_AUDIO) += dw-hdmi-i2s-audio.o obj-$(CONFIG_DRM_DW_HDMI_CEC) += dw-hdmi-cec.odrivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +42
-0@@ -0,0 +1,199 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* +* dw-hdmi-gp-audio.c +* +* Copyright 2020-2022 NXP +*/ +#include <linux/io.h> +#include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/dmaengine.h> +#include <linux/dma-mapping.h> +#include <drm/bridge/dw_hdmi.h> +#include <drm/drm_edid.h> +#include <drm/drm_connector.h> + +#include <sound/hdmi-codec.h> +#include <sound/asoundef.h> +#include <sound/core.h> +#include <sound/initval.h> +#include <sound/pcm.h> +#include <sound/pcm_drm_eld.h> +#include <sound/pcm_iec958.h> +#include <sound/dmaengine_pcm.h> + +#include "dw-hdmi-audio.h" + +#define DRIVER_NAME "dw-hdmi-gp-audio" +#define DRV_NAME "hdmi-gp-audio" + +struct snd_dw_hdmi { +struct dw_hdmi_audio_data data; +struct platform_device *audio_pdev; +unsigned int pos; +}; + +struct dw_hdmi_channel_conf { +u8 conf1; +u8 ca; +}; + +/* drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c line 52
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +10
-0+* The default mapping of ALSA channels to HDMI channels and speaker +* allocation bits. Note that we can't do channel remapping here - +* channels must be in the same order. +* +* Mappings for alsa-lib pcm/surround*.conf files: +* +* Front Sur4.0 Sur4.1 Sur5.0 Sur5.1 Sur7.1 +* Channels 2 4 6 6 6 8 +* +* Our mapping from ALSA channel to CEA686D speaker name and HDMI channel:
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c
Quoted 3 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +3
-0+* +* Number of ALSA channels +* ALSA Channel 2 3 4 5 6 7 8
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c line 56
Quoted 1 line
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +1
-0+* 0 FL:0 = = = = = =
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c line 57
Quoted 1 line
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +1
-0+* 1 FR:1 = = = = = =
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c
Quoted 3 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +3
-0+* 2 FC:3 RL:4 LFE:2 = = = +* 3 RR:5 RL:4 FC:3 = = +* 4 RR:5 RL:4 = =
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c line 61
Quoted 1 line
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +1
-0+* 5 RR:5 = =
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c line 62
Quoted 1 line
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +1
-0+* 6 RC:6 =
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c line 63
Quoted 1 line
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +1
-0+* 7 RLC/FRC RLC/FRC
Quoted 16 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +16
-0+*/ +static struct dw_hdmi_channel_conf default_hdmi_channel_config[7 ] = { + {0x03 ,0x00 },/* FL,FR */ + {0x0b ,0x02 },/* FL,FR,FC */ + {0x33 ,0x08 },/* FL,FR,RL,RR */ + {0x37 ,0x09 },/* FL,FR,LFE,RL,RR */ + {0x3f ,0x0b },/* FL,FR,LFE,FC,RL,RR */ + {0x7f ,0x0f },/* FL,FR,LFE,FC,RL,RR,RC */ + {0xff ,0x13 },/* FL,FR,LFE,FC,RL,RR,[FR]RC,[FR]LC */ }; + +static int audio_hw_params (struct device *dev,void *data, +struct hdmi_codec_daifmt *daifmt, +struct hdmi_codec_params *params) { +struct snd_dw_hdmi *dw =dev_get_drvdata (dev); +int ret =0 ; +u8 ca;drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +10
-0+ +dw_hdmi_set_sample_rate (dw->data.hdmi, params->sample_rate); + + ca = default_hdmi_channel_config[params->channels -2 ].ca; + +dw_hdmi_set_channel_count (dw->data.hdmi, params->channels); +dw_hdmi_set_channel_allocation (dw->data.hdmi, ca); + + dw_hdmi_set_sample_non_pcm(dw->data.hdmi, + params->iec.status[0] &
IEC958_AES0_NONAUDIO);drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c line 90
Quoted 1 line
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +1
-0+ dw_hdmi_set_sample_width(dw->data.hdmi,
params->sample_width);Quoted 60 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +60
-0+ +return ret; +} + +static void audio_shutdown (struct device *dev,void *data) { } + +static int audio_mute_stream (struct device *dev,void *data, +bool enable,int direction) { +struct snd_dw_hdmi *dw =dev_get_drvdata (dev); +int ret =0 ; + +if (!enable) +dw_hdmi_audio_enable (dw->data.hdmi); +else +dw_hdmi_audio_disable (dw->data.hdmi); + +return ret; +} + +static int audio_get_eld (struct device *dev,void *data, +u8 *buf,size_t len) { +struct dw_hdmi_audio_data *audio = data; +u8 *eld; + + eld = audio->get_eld (audio->hdmi); +if (eld) +memcpy (buf, eld,min_t (size_t,MAX_ELD_BYTES , len)); +else +/* Pass en empty ELD if connector not available */ +memset (buf,0 , len); + +return 0 ; +} + +static int audio_hook_plugged_cb (struct device *dev,void *data, +hdmi_codec_plugged_cb fn, +struct device *codec_dev) { +struct snd_dw_hdmi *dw =dev_get_drvdata (dev); + +return dw_hdmi_set_plugged_cb (dw->data.hdmi, fn, codec_dev); } + +static const struct hdmi_codec_ops audio_codec_ops = { + .hw_params = audio_hw_params, + .audio_shutdown = audio_shutdown, + .mute_stream = audio_mute_stream, + .get_eld = audio_get_eld, + .hook_plugged_cb = audio_hook_plugged_cb, }; + +static int snd_dw_hdmi_probe (struct platform_device *pdev) { +struct dw_hdmi_audio_data *data = pdev->dev.platform_data; +struct snd_dw_hdmi *dw; + +const struct hdmi_codec_pdata codec_data = { + .i2s =1 , + .spdif =0 , + .ops = &audio_codec_ops, + .max_i2s_channels =8 , + .data = data, + }; +drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c line 173
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +10
-0+ dw =devm_kzalloc (&pdev->dev,sizeof (*dw),GFP_KERNEL ); +if (!dw) +return -ENOMEM ; + + dw->data = *data; + +platform_set_drvdata (pdev, dw); + + dw->audio_pdev = platform_device_register_data(&pdev->dev, +
HDMI_CODEC_DRV_NAME, 1,drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c line 161
Quoted 1 line
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +1
-0+
&codec_data,Quoted 15 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +15
-0+ + sizeof(codec_data)); + +return PTR_ERR_OR_ZERO (dw->audio_pdev); } + +static int snd_dw_hdmi_remove (struct platform_device *pdev) { +struct snd_dw_hdmi *dw =platform_get_drvdata (pdev); + +platform_device_unregister (dw->audio_pdev); + +return 0 ; +} + +static struct platform_driver snd_dw_hdmi_driver = { + .probe = snd_dw_hdmi_probe,drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +10
-0+ .remove = snd_dw_hdmi_remove, + .driver = { + .name = DRIVER_NAME, + }, +}; + +module_platform_driver (snd_dw_hdmi_driver); + +MODULE_AUTHOR ("Shengjiu Wang <[email protected]>" ); +MODULE_DESCRIPTION("Synopsis Designware HDMI GPA ALSAinterface");
Quoted 1 line
Should be Synopsys
Thanks, I will change it.
Quoted 51 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int
Quoted 20 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-gp-audio.c new file +2
-0+MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:" DRIVER_NAME );drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +3
-0@@ -191,7 +191,10 @@ struct dw_hdmi {spinlock_t audio_lock;struct mutex audio_mutex; +unsigned int sample_non_pcm; +unsigned int sample_width;unsigned int sample_rate; +unsigned int channels;unsigned int audio_cts;unsigned int audio_n;bool audio_enable;@@ -589,6 +592,8 @@ static unsigned int hdmi_compute_n(unsigned intfreq, unsigned long
pixel_clk)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int
Quoted 9 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-0n =4096 ; else if (pixel_clk == 74176000 || pixel_clk == 148352000) n =11648 ; + else if (pixel_clk == 297000000) + n =3072 ; else n =4096 ; n *= mult;@@ -601,6 +606,8 @@ static unsigned int hdmi_compute_n(unsigned intfreq, unsigned long
pixel_clk)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int
Quoted 9 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-0n =17836 ; else if (pixel_clk == 148352000) n =8918 ; + else if (pixel_clk == 297000000) + n =4704 ; else n =6272 ; n *= mult;@@ -615,6 +622,8 @@ static unsigned int hdmi_compute_n(unsigned intfreq, unsigned long
pixel_clk)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_set_clk_regenerator(struct
Quoted 9 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-0n =11648 ; else if (pixel_clk == 148352000) n =5824 ; + else if (pixel_clk == 297000000) + n =5120 ; else n =6144 ; n *= mult;@@ -660,7 +669,7 @@ static void hdmi_set_clk_regenerator(struct
dw_hdmi*hdmi,
Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi, · line 671
Quoted 3 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-0config3 =hdmi_readb (hdmi,HDMI_CONFIG3_ID );/* Only compute CTS when using internal AHB audio */ Please update the comment to include GPAUD as I requested on V1.
OK.
Quoted 92 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_set_clk_regenerator(struct · line 675
Quoted 6 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-1-if (config3 &HDMI_CONFIG3_AHBAUDDMA ) { +if ((config3 &HDMI_CONFIG3_AHBAUDDMA ) || (config3 & +HDMI_CONFIG3_GPAUD )) {/* * Compute the CTS value from the N value. Note that CTS and N
Quoted 2 lines
* can be up to 20 bits in total, so we need 64-bit
math. Also @@ -702,6 +711,22 @@ static void
hdmi_clk_regenerator_update_pixel_clock(struct dw_hdmi *hdmi)Quoted 8 lines
mutex_unlock(&hdmi->audio_mutex);}
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +5
-0+void dw_hdmi_set_sample_width (struct dw_hdmi *hdmi,unsigned int +width) { +mutex_lock (&hdmi->audio_mutex); + hdmi->sample_width = width; +mutex_unlock (&hdmi->audio_mutex); }drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void hdmi_clk_regenerator_update_pixel_clock(struct dw_hdmi *hdmi)
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +9
-0+EXPORT_SYMBOL_GPL (dw_hdmi_set_sample_width); + +void dw_hdmi_set_sample_non_pcm (struct dw_hdmi *hdmi,unsigned int +non_pcm) { +mutex_lock (&hdmi->audio_mutex); + hdmi->sample_non_pcm = non_pcm; +mutex_unlock (&hdmi->audio_mutex); } +EXPORT_SYMBOL_GPL (dw_hdmi_set_sample_non_pcm); + void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned intrate)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c void dw_hdmi_set_channel_count(struct dw_hdmi
Quoted 3 lines
{ mutex_lock(&hdmi->audio_mutex);drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-0@@ -717,6 +742,7 @@ void dw_hdmi_set_channel_count(struct dw_hdmi*hdmi, unsigned int cnt)
Quoted 48 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +38
-1u8 layout;mutex_lock (&hdmi->audio_mutex); + hdmi->channels = cnt;/* * For >2 channel PCM audio, we need to select layout 1 @@ -765,6 +791,87 @@ static u8 *hdmi_audio_get_eld(struct dw_hdmi *hdmi) return hdmi->curr_conn->eld; } +static void dw_hdmi_gp_audio_enable(struct dw_hdmi *hdmi) { +int sample_freq = 0x2, org_sample_freq = 0xD; +int ch_mask = BIT(hdmi->channels) - 1; + +switch (hdmi->sample_rate) { +case 32000: +sample_freq = 0x03; +org_sample_freq = 0x0C; +break; +case 44100: +sample_freq = 0x00; +org_sample_freq = 0x0F; +break; +case 48000: +sample_freq = 0x02; +org_sample_freq = 0x0D; +break; +case 88200: +sample_freq = 0x08; +org_sample_freq = 0x07; +break; +case 96000: +sample_freq = 0x0A; +org_sample_freq = 0x05; +break; +case 176400: +sample_freq = 0x0C; +org_sample_freq = 0x03; +break; +case 192000: +sample_freq = 0x0E; +org_sample_freq = 0x01; +break; +default: +break; +} +drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static u8 *hdmi_audio_get_eld(struct dw_hdmi *hdmi)
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +10
-0+hdmi_set_cts_n (hdmi, hdmi->audio_cts, hdmi->audio_n); +hdmi_enable_audio_clk (hdmi, true); + +hdmi_writeb (hdmi,0x1 ,HDMI_FC_AUDSCHNLS0 ); +hdmi_writeb (hdmi, hdmi->channels,HDMI_FC_AUDSCHNLS2 ); +hdmi_writeb (hdmi,0x22 ,HDMI_FC_AUDSCHNLS3 ); +hdmi_writeb (hdmi,0x22 ,HDMI_FC_AUDSCHNLS4 ); +hdmi_writeb (hdmi,0x11 ,HDMI_FC_AUDSCHNLS5 ); +hdmi_writeb (hdmi,0x11 ,HDMI_FC_AUDSCHNLS6 ); + hdmi_writeb(hdmi, (0x3 << 4) | sample_freq,
HDMI_FC_AUDSCHNLS7);
Quoted 16 lines
Quoted 4 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4
-0+hdmi_writeb (hdmi, (org_sample_freq <<4 ) |0xb , +HDMI_FC_AUDSCHNLS8 ); + +hdmi_writeb (hdmi, ch_mask,HDMI_GP_CONF1 );drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static u8 *hdmi_audio_get_eld(struct dw_hdmi *hdmi) · line 854
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +10
-0+hdmi_writeb (hdmi,0x02 ,HDMI_GP_CONF2 ); +hdmi_writeb (hdmi,0x01 ,HDMI_GP_CONF0 ); + +hdmi_modb (hdmi,0x3 ,0x3 ,HDMI_FC_DATAUTO3 ); + +/* hbr */ +if (hdmi->sample_rate ==192000 && hdmi->channels ==8 && + hdmi->sample_width ==32 && hdmi->sample_non_pcm) { +hdmi_modb (hdmi,0x01 ,0x01 ,HDMI_GP_CONF2 ); + }You can drop the brackets here
OK.
Quoted 11 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static u8 *hdmi_audio_get_eld(struct dw_hdmi *hdmi) · line 863
Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +7
-0+ +if (hdmi->phy.ops->enable_audio) + hdmi->phy.ops->enable_audio(hdmi, hdmi->phy.data, + hdmi->channels, + hdmi->sample_width, + hdmi->sample_rate, +
hdmi->sample_non_pcm);Are this really PHY ops ? or glue ops ? it looks like it's the later.
Sure, it is not really PHY ops.
Quoted 6 lines
Those should eventually go in
dw_hdmi_plat_data.Can you elaborate what is done in those callbacks ? can't you use alsa codecs events instead ?
There is a Parallel Audio Interface between of hdmi TX and audio subsystem. This PAI includes IEC60958 component muxing, BPreamble decoding,
and intermediate storage to queue results prior to being passed to the HDMI TX GPA Interface. PAI is part of HDMI subsystem, so it is more reasonable to be enable/disable in HDMI driver. I will move those callbacks to dw_hdmi_plat_data.
B.R
Sandor
Quoted 107 lines
Quoted 4 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4
-0+} + +static void dw_hdmi_gp_audio_disable (struct dw_hdmi *hdmi) { +hdmi_set_cts_n (hdmi, hdmi->audio_cts,0 );drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static u8 *hdmi_audio_get_eld(struct dw_hdmi *hdmi)
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +7
-0+ +hdmi_modb (hdmi,0 ,0x3 ,HDMI_FC_DATAUTO3 ); +if (hdmi->phy.ops->disable_audio) + hdmi->phy.ops->disable_audio (hdmi, hdmi->phy.data); + +hdmi_enable_audio_clk (hdmi, false); } +static void dw_hdmi_ahb_audio_enable (struct dw_hdmi *hdmi) { hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n); @@-3253,6
Quoted 1 line
+3360,7 @@ struct
dw_hdmi*dw_hdmi_probe(structplatform_device*pdev,
Quoted 7 lines
hdmi->plat_data = plat_data; hdmi->dev = dev; hdmi->sample_rate = 48000; + hdmi->channels = 2; hdmi->disabled = true; hdmi->rxsense = true; hdmi->phy_mask = (u8)~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE);@@
Quoted 1 line
-3476,6 +3584,24 @@ struct
dw_hdmi*dw_hdmi_probe(struct
platform_device*pdev,Quoted 50 lines
pdevinfo.size_data = sizeof(audio); pdevinfo.dma_mask = DMA_BIT_MASK(32); hdmi->audio = platform_device_register_full(&pdevinfo);drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +18
-0+ }else if (iores && config3 &HDMI_CONFIG3_GPAUD ) { +struct dw_hdmi_audio_data audio; + + audio.phys = iores->start; + audio.base = hdmi->regs; + audio.irq = irq; + audio.hdmi = hdmi; + audio.get_eld = hdmi_audio_get_eld; + + hdmi->enable_audio = dw_hdmi_gp_audio_enable; + hdmi->disable_audio = dw_hdmi_gp_audio_disable; + + pdevinfo.name ="dw-hdmi-gp-audio" ; + pdevinfo.id =PLATFORM_DEVID_NONE ; + pdevinfo.data = &audio; + pdevinfo.size_data =sizeof (audio); + pdevinfo.dma_mask =DMA_BIT_MASK (32 ); + hdmi->audio =platform_device_register_full (&pdevinfo); }if (!plat_data->disable_cec && (config0 &HDMI_CONFIG0_CEC )) {drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +11
-2@@ -158,8 +158,17 @@#define HDMI_FC_SPDDEVICEINF 0x1062#define HDMI_FC_AUDSCONF 0x1063#define HDMI_FC_AUDSSTAT 0x1064 -#define HDMI_FC_AUDSCHNLS7 0x106e -#define HDMI_FC_AUDSCHNLS8 0x106f +#define HDMI_FC_AUDSV 0x1065 +#define HDMI_FC_AUDSU 0x1066 +#define HDMI_FC_AUDSCHNLS0 0x1067 +#define HDMI_FC_AUDSCHNLS1 0x1068 +#define HDMI_FC_AUDSCHNLS2 0x1069 +#define HDMI_FC_AUDSCHNLS3 0x106A +#define HDMI_FC_AUDSCHNLS4 0x106B +#define HDMI_FC_AUDSCHNLS5 0x106C +#define HDMI_FC_AUDSCHNLS6 0x106D +#define HDMI_FC_AUDSCHNLS7 0x106E +#define HDMI_FC_AUDSCHNLS8 0x106F#define HDMI_FC_DATACH0FILL 0x1070#define HDMI_FC_DATACH1FILL 0x1071#define HDMI_FC_DATACH2FILL 0x1072(quoted diff) +0
-0Quoted 1 line
b/include/drm/bridge/dw_hdmi.hindex70082f80a8c8..7f73c3398a54100644
include/drm/bridge/dw_hdmi.h void dw_hdmi_setup_rx_sense(struct dw_hdmi
Quoted 13 lines
include/drm/bridge/dw_hdmi.h +3
-0@@ -121,6 +121,9 @@ struct dw_hdmi_phy_ops {void (*update_hpd)(struct dw_hdmi *hdmi,void *data,bool force,bool disabled,bool rxsense);void (*setup_hpd)(struct dw_hdmi *hdmi,void *data); +void (*enable_audio)(struct dw_hdmi *hdmi,void *data,int channel, +int width,int rate,int non_pcm); +void (*disable_audio)(struct dw_hdmi *hdmi,void *data); };struct dw_hdmi_plat_data {@@ -173,6 +176,8 @@ void dw_hdmi_setup_rx_sense(struct dw_hdmi*hdmi,
include/drm/bridge/dw_hdmi.h void dw_hdmi_setup_rx_sense(struct dw_hdmi · line 178
Quoted 3 lines
include/drm/bridge/dw_hdmi.h +0
-0bool hpd, bool rx_sense); int dw_hdmi_set_plugged_cb(struct dw_hdmi *hdmi,
hdmi_codec_plugged_cbfn,include/drm/bridge/dw_hdmi.h void dw_hdmi_setup_rx_sense(struct dw_hdmi · line 183
Quoted 5 lines
include/drm/bridge/dw_hdmi.h +3
-0struct device *codec_dev); +void dw_hdmi_set_sample_non_pcm (struct dw_hdmi *hdmi,unsigned int +non_pcm);void dw_hdmi_set_sample_width (struct dw_hdmi *hdmi, +unsigned int width); void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned intrate);
Quoted 1 line
void dw_hdmi_set_channel_count(struct
dw_hdmi*hdmi, unsigned intcnt);
Quoted 2 lines
void dw_hdmi_set_channel_status(struct
dw_hdmi*hdmi, u8*channel_status);