drm/amdgpu/soc15: skip reset on init
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/21 drm/amdgpu/soc15: skip reset on init
From: Alex Deucher <[email protected]>
Not necessary on soc15 and breaks driver reload on server cards.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc15.c +5 -0
@@ -730,6 +730,11 @@ static bool soc15_need_reset_on_init(struct amdgpu_device *adev) {u32 sol_reg; +/* Just return false for soc15 GPUs. Reset does not seem to +* be necessary. +*/ +return false; +if (adev->flags &AMD_IS_APU )return false;
PATCH 5/21 drm/i915/dsi: Use a fuzzy check for burst mode clock check
In reply to a message not in the archiveFrom: Hans de Goede <[email protected]>
Prior to this commit we fail to init the DSI panel on the GPD MicroPC:
https://www.indiegogo.com/projects/gpd-micropc-6-inch-handheld-industry-laptop#/
The problem is intel_dsi_vbt_init() failing with the following error:
*ERROR* Burst mode freq is less than computed
The pclk in the VBT panel modeline is 70000, together with 24 bpp and 4 lines this results in a bitrate value of 70000 * 24 / 4 = 420000. But the target_burst_mode_freq in the VBT is 418000.
This commit works around this problem by adding an intel_fuzzy_clock_check when target_burst_mode_freq < bitrate and setting target_burst_mode_freq to bitrate when that checks succeeds, fixing the panel not working.
--- drivers/gpu/drm/i915/intel_display.c | 2 +- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_dsi_vbt.c | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -12163,7 +12163,7 @@ intel_modeset_pipe_config(struct intel_crtc_state *pipe_config)return 0 ; } -static bool intel_fuzzy_clock_check (int clock1,int clock2) +bool intel_fuzzy_clock_check (int clock1,int clock2) {int diff;
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -1557,6 +1557,7 @@ int vlv_force_pll_on(struct drm_i915_private *dev_priv, enum pipe pipe, const struct dpll *dpll);void vlv_force_pll_off (struct drm_i915_private *dev_priv,enum pipe pipe);int lpt_get_iclkip (struct drm_i915_private *dev_priv); +bool intel_fuzzy_clock_check (int clock1,int clock2);/* modesetting asserts */ void assert_panel_unlocked(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_dsi_vbt.c +11 -0
@@ -858,6 +858,17 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id)if (mipi_config->target_burst_mode_freq) {u32 bitrate =intel_dsi_bitrate (intel_dsi); +/* +* Sometimes the VBT contains a slightly lower clock, +* then the bitrate we have calculated, in this case +* just replace it with the calculated bitrate. +*/ +if (mipi_config->target_burst_mode_freq < bitrate && +intel_fuzzy_clock_check ( + mipi_config->target_burst_mode_freq, + bitrate)) + mipi_config->target_burst_mode_freq = bitrate; +if (mipi_config->target_burst_mode_freq < bitrate) {DRM_ERROR ("Burst mode freq is less than computed\n" );return false;
PATCH 8/21 drm/i915/dmc: protect against reading random memory
In reply to a message not in the archiveFrom: Lucas De Marchi <[email protected]>
While loading the DMC firmware we were double checking the headers made sense, but in no place we checked that we were actually reading memory we were supposed to. This could be wrong in case the firmware file is truncated or malformed.
Before this patch:
# ls -l /lib/firmware/i915/icl_dmc_ver1_07.bin -rw-r--r-- 1 root root 25716 Feb 1 12:26 icl_dmc_ver1_07.bin # truncate -s 25700 /lib/firmware/i915/icl_dmc_ver1_07.bin # modprobe i915 # dmesg| grep -i dmc [drm:intel_csr_ucode_init [i915]] Loading i915/icl_dmc_ver1_07.bin [drm] Finished loading DMC firmware i915/icl_dmc_ver1_07.bin (v1.7)
i.e. it loads random data. Now it fails like below:
[drm:intel_csr_ucode_init [i915]] Loading i915/icl_dmc_ver1_07.bin [drm:csr_load_work_fn [i915]] *ERROR* Truncated DMC firmware, rejecting. i915 0000:00:02.0: Failed to load DMC firmware i915/icl_dmc_ver1_07.bin. Disabling runtime power management. i915 0000:00:02.0: DMC firmware homepage: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915
Before reading any part of the firmware file, validate the input first.
--- drivers/gpu/drm/i915/intel_csr.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/gpu/drm/i915/intel_csr.c +18 -0
@@ -303,10 +303,17 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,u32 dmc_offset =CSR_DEFAULT_FW_OFFSET , readcount =0 , nbytes;u32 i;u32 *dmc_payload; +size_t fsize;if (!fw)return NULL ; + fsize =sizeof (struct intel_css_header ) + +sizeof (struct intel_package_header ) + +sizeof (struct intel_dmc_header ); +if (fsize > fw->size) + goto error_truncated; +/* Extract CSS Header information*/ css_header = (struct intel_css_header *)fw->data; if (sizeof(struct intel_css_header) !=
@@ -366,6 +373,9 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,/* Convert dmc_offset into number of bytes. By default it is in dwords*/ dmc_offset *=4 ; readcount += dmc_offset; + fsize += dmc_offset; +if (fsize > fw->size) + goto error_truncated;/* Extract dmc_header information. */ dmc_header = (struct intel_dmc_header *)&fw->data[readcount];
@@ -397,6 +407,10 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,/* fw_size is in dwords, so multiplied by 4 to convert into bytes. */ nbytes = dmc_header->fw_size *4 ; + fsize += nbytes; +if (fsize > fw->size) + goto error_truncated; +if (nbytes > csr->max_fw_size) {DRM_ERROR ("DMC FW too big (%u bytes)\n" , nbytes);return NULL ;
@@ -410,6 +424,10 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv, }return memcpy (dmc_payload, &fw->data[readcount], nbytes); + +error_truncated: +DRM_ERROR ("Truncated DMC firmware, rejecting.\n" ); +return NULL ; }static void intel_csr_runtime_pm_get (struct drm_i915_private *dev_priv)
PATCH 9/21 drm/i915: Fix per-pixel alpha with CCS
In reply to a message not in the archiveFrom: Ville Syrjälä <[email protected]>
We forgot to set .has_alpha=true for the A+CCS formats when the code started to consult .has_alpha. This manifests as A+CCS being treated as X+CCS which means no per-pixel alpha blending. Fix the format list appropriately.
--- drivers/gpu/drm/i915/intel_display.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_display.c +8 -4
@@ -2463,10 +2463,14 @@ static unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier)* main surface. */ static const struct drm_format_info ccs_formats[] = { - { .format =DRM_FORMAT_XRGB8888 , .depth =24 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, - { .format =DRM_FORMAT_XBGR8888 , .depth =24 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, - { .format =DRM_FORMAT_ARGB8888 , .depth =32 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, - { .format =DRM_FORMAT_ABGR8888 , .depth =32 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, + { .format =DRM_FORMAT_XRGB8888 , .depth =24 , .num_planes =2 , + .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, + { .format =DRM_FORMAT_XBGR8888 , .depth =24 , .num_planes =2 , + .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, + { .format =DRM_FORMAT_ARGB8888 , .depth =32 , .num_planes =2 , + .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , .has_alpha = true, }, + { .format =DRM_FORMAT_ABGR8888 , .depth =32 , .num_planes =2 , + .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , .has_alpha = true, }, }; static const struct drm_format_info *
PATCH 10/21 drm/i915/sdvo: Implement proper HDMI audio support for SDVO
In reply to a message not in the archiveFrom: Ville Syrjälä <[email protected]>
Our SDVO audio support is pretty bogus. We can't push audio over the SDVO bus, so trying to enable audio in the SDVO control register doesn't do anything. In fact it looks like the SDVO encoder will always mix in the audio coming over HDA, and there's no (at least documented) way to disable that from our side. So HDMI audio does work currently on gen4 but only by luck really. On gen3 it got broken by the referenced commit. And what has always been missing on every platform is the ELD.
To pass the ELD to the audio driver we need to write it to magic buffer in the SDVO encoder hardware which then gets pulled out via HDA in the other end. Ie. pretty much the same thing we had for native HDMI before we started to just pass the ELD between the drivers. This sort of explains why we even have that silly hardware buffer with native HDMI.
$ cat /proc/asound/card0/eld#1.0 -monitor_present 0 -eld_valid 0 +monitor_present 1 +eld_valid 1 +monitor_name LG TV +connection_type HDMI +...
This also fixes our state readout since we can now query the SDVO encoder about the state of the "ELD valid" and "presence detect" bits. As mentioned those don't actually control whether audio gets sent over the HDMI cable, but it's the best we can do. And with the state checker appeased we can re-enable HDMI audio for gen3.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108976
--- drivers/gpu/drm/i915/intel_sdvo.c | 58 +++++++++++++++++++++----- drivers/gpu/drm/i915/intel_sdvo_regs.h | 3 ++ 2 files changed, 50 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +47 -11
@@ -920,6 +920,13 @@ static bool intel_sdvo_set_colorimetry(struct intel_sdvo *intel_sdvo,return intel_sdvo_set_value (intel_sdvo,SDVO_CMD_SET_COLORIMETRY , &mode,1 ); } +static bool intel_sdvo_set_audio_state (struct intel_sdvo *intel_sdvo, +u8 audio_state) +{ +return intel_sdvo_set_value (intel_sdvo,SDVO_CMD_SET_AUDIO_STAT , + &audio_state,1 ); +} +#if 0 static void intel_sdvo_dump_hdmi_buf (struct intel_sdvo *intel_sdvo) {
@@ -1491,11 +1498,6 @@ static void intel_sdvo_pre_enable(struct intel_encoder *intel_encoder,else sdvox |=SDVO_PIPE_SEL (crtc->pipe); -if (crtc_state->has_audio) { -WARN_ON_ONCE (INTEL_GEN (dev_priv) <4 ); - sdvox |=SDVO_AUDIO_ENABLE ; - } -if (INTEL_GEN (dev_priv) >=4 ) {/* done in crtc_mode_set as the dpll_md reg must be written early */ } else if (IS_I945G(dev_priv) || IS_I945GM(dev_priv) ||
@@ -1639,8 +1641,13 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,if (sdvox &HDMI_COLOR_RANGE_16_235 ) pipe_config->limited_color_range = true; -if (sdvox &SDVO_AUDIO_ENABLE ) - pipe_config->has_audio = true; +if (intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_AUDIO_STAT , + &val,1 )) { +u8 mask =SDVO_AUDIO_ELD_VALID |SDVO_AUDIO_PRESENCE_DETECT ; + +if ((val & mask) == mask) + pipe_config->has_audio = true; + }if (intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_ENCODE , &val,1 )) {
@@ -1651,6 +1658,32 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,intel_sdvo_get_avi_infoframe (intel_sdvo, pipe_config); } +static void intel_sdvo_disable_audio (struct intel_sdvo *intel_sdvo) +{ +intel_sdvo_set_audio_state (intel_sdvo,0 ); +} + +static void intel_sdvo_enable_audio (struct intel_sdvo *intel_sdvo, +const struct intel_crtc_state *crtc_state, +const struct drm_connector_state *conn_state) +{ +const struct drm_display_mode *adjusted_mode = + &crtc_state->base.adjusted_mode; +struct drm_connector *connector = conn_state->connector; +u8 *eld = connector->eld; + + eld[6 ] =drm_av_sync_delay (connector, adjusted_mode) /2 ; + +intel_sdvo_set_audio_state (intel_sdvo,0 ); + +intel_sdvo_write_infoframe (intel_sdvo,SDVO_HBUF_INDEX_ELD , +SDVO_HBUF_TX_DISABLED , + eld,drm_eld_size (eld)); + +intel_sdvo_set_audio_state (intel_sdvo,SDVO_AUDIO_ELD_VALID | +SDVO_AUDIO_PRESENCE_DETECT ); +} +static void intel_disable_sdvo (struct intel_encoder *encoder,const struct intel_crtc_state *old_crtc_state,const struct drm_connector_state *conn_state)
@@ -1660,6 +1693,9 @@ static void intel_disable_sdvo(struct intel_encoder *encoder,struct intel_crtc *crtc =to_intel_crtc (old_crtc_state->base.crtc);u32 temp; +if (old_crtc_state->has_audio) +intel_sdvo_disable_audio (intel_sdvo); +intel_sdvo_set_active_outputs (intel_sdvo,0 );if (0 ) intel_sdvo_set_encoder_power_state(intel_sdvo,
@@ -1745,6 +1781,9 @@ static void intel_enable_sdvo(struct intel_encoder *encoder,intel_sdvo_set_encoder_power_state (intel_sdvo,DRM_MODE_DPMS_ON );intel_sdvo_set_active_outputs (intel_sdvo, intel_sdvo->attached_output); + +if (pipe_config->has_audio) +intel_sdvo_enable_audio (intel_sdvo, pipe_config, conn_state); } static enum drm_mode_status
@@ -2607,7 +2646,6 @@ static bool intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device) {struct drm_encoder *encoder = &intel_sdvo->base.base; -struct drm_i915_private *dev_priv =to_i915 (encoder->dev);struct drm_connector *connector;struct intel_encoder *intel_encoder =to_intel_encoder (encoder);struct intel_connector *intel_connector;
@@ -2644,9 +2682,7 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device) encoder->encoder_type =DRM_MODE_ENCODER_TMDS ; connector->connector_type =DRM_MODE_CONNECTOR_DVID ; -/* gen3 doesn't do the hdmi bits in the SDVO register */ -if (INTEL_GEN (dev_priv) >=4 && -intel_sdvo_is_hdmi_connector (intel_sdvo, device)) { +if (intel_sdvo_is_hdmi_connector (intel_sdvo, device)) { connector->connector_type =DRM_MODE_CONNECTOR_HDMIA ; intel_sdvo_connector->is_hdmi = true; }
drivers/gpu/drm/i915/intel_sdvo_regs.h +3 -0
@@ -707,6 +707,9 @@ struct intel_sdvo_enhancements_arg {#define SDVO_CMD_GET_AUDIO_ENCRYPT_PREFER 0x90#define SDVO_CMD_SET_AUDIO_STAT 0x91#define SDVO_CMD_GET_AUDIO_STAT 0x92 +#define SDVO_AUDIO_ELD_VALID (1 << 0) +#define SDVO_AUDIO_PRESENCE_DETECT (1 << 1) +#define SDVO_AUDIO_CP_READY (1 << 2)#define SDVO_CMD_SET_HBUF_INDEX 0x93#define SDVO_HBUF_INDEX_ELD 0#define SDVO_HBUF_INDEX_AVI_IF 1
PATCH 14/21 drm/i915/dsi: Use a fuzzy check for burst mode clock check
In reply to a message not in the archiveFrom: Hans de Goede <[email protected]>
Prior to this commit we fail to init the DSI panel on the GPD MicroPC:
https://www.indiegogo.com/projects/gpd-micropc-6-inch-handheld-industry-laptop#/
The problem is intel_dsi_vbt_init() failing with the following error:
*ERROR* Burst mode freq is less than computed
The pclk in the VBT panel modeline is 70000, together with 24 bpp and 4 lines this results in a bitrate value of 70000 * 24 / 4 = 420000. But the target_burst_mode_freq in the VBT is 418000.
This commit works around this problem by adding an intel_fuzzy_clock_check when target_burst_mode_freq < bitrate and setting target_burst_mode_freq to bitrate when that checks succeeds, fixing the panel not working.
--- drivers/gpu/drm/i915/intel_display.c | 2 +- drivers/gpu/drm/i915/intel_drv.h | 1 + drivers/gpu/drm/i915/intel_dsi_vbt.c | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
@@ -11942,7 +11942,7 @@ intel_modeset_pipe_config(struct drm_crtc *crtc,return 0 ; } -static bool intel_fuzzy_clock_check (int clock1,int clock2) +bool intel_fuzzy_clock_check (int clock1,int clock2) {int diff;
drivers/gpu/drm/i915/intel_drv.h +1 -0
@@ -1742,6 +1742,7 @@ int vlv_force_pll_on(struct drm_i915_private *dev_priv, enum pipe pipe, const struct dpll *dpll);void vlv_force_pll_off (struct drm_i915_private *dev_priv,enum pipe pipe);int lpt_get_iclkip (struct drm_i915_private *dev_priv); +bool intel_fuzzy_clock_check (int clock1,int clock2);/* modesetting asserts */ void assert_panel_unlocked(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_dsi_vbt.c +11 -0
@@ -853,6 +853,17 @@ bool intel_dsi_vbt_init(struct intel_dsi *intel_dsi, u16 panel_id)if (mipi_config->target_burst_mode_freq) {u32 bitrate =intel_dsi_bitrate (intel_dsi); +/* +* Sometimes the VBT contains a slightly lower clock, +* then the bitrate we have calculated, in this case +* just replace it with the calculated bitrate. +*/ +if (mipi_config->target_burst_mode_freq < bitrate && +intel_fuzzy_clock_check ( + mipi_config->target_burst_mode_freq, + bitrate)) + mipi_config->target_burst_mode_freq = bitrate; +if (mipi_config->target_burst_mode_freq < bitrate) {DRM_ERROR ("Burst mode freq is less than computed\n" );return false;
PATCH 15/21 drm/i915/dmc: protect against reading random memory
In reply to a message not in the archiveFrom: Lucas De Marchi <[email protected]>
While loading the DMC firmware we were double checking the headers made sense, but in no place we checked that we were actually reading memory we were supposed to. This could be wrong in case the firmware file is truncated or malformed.
Before this patch:
# ls -l /lib/firmware/i915/icl_dmc_ver1_07.bin -rw-r--r-- 1 root root 25716 Feb 1 12:26 icl_dmc_ver1_07.bin # truncate -s 25700 /lib/firmware/i915/icl_dmc_ver1_07.bin # modprobe i915 # dmesg| grep -i dmc [drm:intel_csr_ucode_init [i915]] Loading i915/icl_dmc_ver1_07.bin [drm] Finished loading DMC firmware i915/icl_dmc_ver1_07.bin (v1.7)
i.e. it loads random data. Now it fails like below:
[drm:intel_csr_ucode_init [i915]] Loading i915/icl_dmc_ver1_07.bin [drm:csr_load_work_fn [i915]] *ERROR* Truncated DMC firmware, rejecting. i915 0000:00:02.0: Failed to load DMC firmware i915/icl_dmc_ver1_07.bin. Disabling runtime power management. i915 0000:00:02.0: DMC firmware homepage: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915
Before reading any part of the firmware file, validate the input first.
--- drivers/gpu/drm/i915/intel_csr.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/gpu/drm/i915/intel_csr.c +18 -0
@@ -303,10 +303,17 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,u32 dmc_offset =CSR_DEFAULT_FW_OFFSET , readcount =0 , nbytes;u32 i;u32 *dmc_payload; +size_t fsize;if (!fw)return NULL ; + fsize =sizeof (struct intel_css_header ) + +sizeof (struct intel_package_header ) + +sizeof (struct intel_dmc_header ); +if (fsize > fw->size) + goto error_truncated; +/* Extract CSS Header information*/ css_header = (struct intel_css_header *)fw->data; if (sizeof(struct intel_css_header) !=
@@ -366,6 +373,9 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,/* Convert dmc_offset into number of bytes. By default it is in dwords*/ dmc_offset *=4 ; readcount += dmc_offset; + fsize += dmc_offset; +if (fsize > fw->size) + goto error_truncated;/* Extract dmc_header information. */ dmc_header = (struct intel_dmc_header *)&fw->data[readcount];
@@ -397,6 +407,10 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv,/* fw_size is in dwords, so multiplied by 4 to convert into bytes. */ nbytes = dmc_header->fw_size *4 ; + fsize += nbytes; +if (fsize > fw->size) + goto error_truncated; +if (nbytes > csr->max_fw_size) {DRM_ERROR ("DMC FW too big (%u bytes)\n" , nbytes);return NULL ;
@@ -410,6 +424,10 @@ static u32 *parse_csr_fw(struct drm_i915_private *dev_priv, }return memcpy (dmc_payload, &fw->data[readcount], nbytes); + +error_truncated: +DRM_ERROR ("Truncated DMC firmware, rejecting.\n" ); +return NULL ; }static void intel_csr_runtime_pm_get (struct drm_i915_private *dev_priv)
PATCH 16/21 drm/i915: Fix per-pixel alpha with CCS
In reply to a message not in the archiveFrom: Ville Syrjälä <[email protected]>
We forgot to set .has_alpha=true for the A+CCS formats when the code started to consult .has_alpha. This manifests as A+CCS being treated as X+CCS which means no per-pixel alpha blending. Fix the format list appropriately.
--- drivers/gpu/drm/i915/intel_display.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/intel_display.c +8 -4
@@ -2432,10 +2432,14 @@ static unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier)* main surface. */ static const struct drm_format_info ccs_formats[] = { - { .format =DRM_FORMAT_XRGB8888 , .depth =24 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, - { .format =DRM_FORMAT_XBGR8888 , .depth =24 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, - { .format =DRM_FORMAT_ARGB8888 , .depth =32 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, - { .format =DRM_FORMAT_ABGR8888 , .depth =32 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, + { .format =DRM_FORMAT_XRGB8888 , .depth =24 , .num_planes =2 , + .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, + { .format =DRM_FORMAT_XBGR8888 , .depth =24 , .num_planes =2 , + .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, + { .format =DRM_FORMAT_ARGB8888 , .depth =32 , .num_planes =2 , + .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , .has_alpha = true, }, + { .format =DRM_FORMAT_ABGR8888 , .depth =32 , .num_planes =2 , + .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , .has_alpha = true, }, }; static const struct drm_format_info *
PATCH 17/21 drm/i915/sdvo: Implement proper HDMI audio support for SDVO
In reply to a message not in the archiveFrom: Ville Syrjälä <[email protected]>
Our SDVO audio support is pretty bogus. We can't push audio over the SDVO bus, so trying to enable audio in the SDVO control register doesn't do anything. In fact it looks like the SDVO encoder will always mix in the audio coming over HDA, and there's no (at least documented) way to disable that from our side. So HDMI audio does work currently on gen4 but only by luck really. On gen3 it got broken by the referenced commit. And what has always been missing on every platform is the ELD.
To pass the ELD to the audio driver we need to write it to magic buffer in the SDVO encoder hardware which then gets pulled out via HDA in the other end. Ie. pretty much the same thing we had for native HDMI before we started to just pass the ELD between the drivers. This sort of explains why we even have that silly hardware buffer with native HDMI.
$ cat /proc/asound/card0/eld#1.0 -monitor_present 0 -eld_valid 0 +monitor_present 1 +eld_valid 1 +monitor_name LG TV +connection_type HDMI +...
This also fixes our state readout since we can now query the SDVO encoder about the state of the "ELD valid" and "presence detect" bits. As mentioned those don't actually control whether audio gets sent over the HDMI cable, but it's the best we can do. And with the state checker appeased we can re-enable HDMI audio for gen3.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108976
--- drivers/gpu/drm/i915/intel_sdvo.c | 58 +++++++++++++++++++++----- drivers/gpu/drm/i915/intel_sdvo_regs.h | 3 ++ 2 files changed, 50 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +47 -11
@@ -916,6 +916,13 @@ static bool intel_sdvo_set_colorimetry(struct intel_sdvo *intel_sdvo,return intel_sdvo_set_value (intel_sdvo,SDVO_CMD_SET_COLORIMETRY , &mode,1 ); } +static bool intel_sdvo_set_audio_state (struct intel_sdvo *intel_sdvo, +u8 audio_state) +{ +return intel_sdvo_set_value (intel_sdvo,SDVO_CMD_SET_AUDIO_STAT , + &audio_state,1 ); +} +#if 0 static void intel_sdvo_dump_hdmi_buf (struct intel_sdvo *intel_sdvo) {
@@ -1487,11 +1494,6 @@ static void intel_sdvo_pre_enable(struct intel_encoder *intel_encoder,else sdvox |=SDVO_PIPE_SEL (crtc->pipe); -if (crtc_state->has_audio) { -WARN_ON_ONCE (INTEL_GEN (dev_priv) <4 ); - sdvox |=SDVO_AUDIO_ENABLE ; - } -if (INTEL_GEN (dev_priv) >=4 ) {/* done in crtc_mode_set as the dpll_md reg must be written early */ } else if (IS_I945G(dev_priv) || IS_I945GM(dev_priv) ||
@@ -1635,8 +1637,13 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,if (sdvox &HDMI_COLOR_RANGE_16_235 ) pipe_config->limited_color_range = true; -if (sdvox &SDVO_AUDIO_ENABLE ) - pipe_config->has_audio = true; +if (intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_AUDIO_STAT , + &val,1 )) { +u8 mask =SDVO_AUDIO_ELD_VALID |SDVO_AUDIO_PRESENCE_DETECT ; + +if ((val & mask) == mask) + pipe_config->has_audio = true; + }if (intel_sdvo_get_value (intel_sdvo,SDVO_CMD_GET_ENCODE , &val,1 )) {
@@ -1647,6 +1654,32 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,intel_sdvo_get_avi_infoframe (intel_sdvo, pipe_config); } +static void intel_sdvo_disable_audio (struct intel_sdvo *intel_sdvo) +{ +intel_sdvo_set_audio_state (intel_sdvo,0 ); +} + +static void intel_sdvo_enable_audio (struct intel_sdvo *intel_sdvo, +const struct intel_crtc_state *crtc_state, +const struct drm_connector_state *conn_state) +{ +const struct drm_display_mode *adjusted_mode = + &crtc_state->base.adjusted_mode; +struct drm_connector *connector = conn_state->connector; +u8 *eld = connector->eld; + + eld[6 ] =drm_av_sync_delay (connector, adjusted_mode) /2 ; + +intel_sdvo_set_audio_state (intel_sdvo,0 ); + +intel_sdvo_write_infoframe (intel_sdvo,SDVO_HBUF_INDEX_ELD , +SDVO_HBUF_TX_DISABLED , + eld,drm_eld_size (eld)); + +intel_sdvo_set_audio_state (intel_sdvo,SDVO_AUDIO_ELD_VALID | +SDVO_AUDIO_PRESENCE_DETECT ); +} +static void intel_disable_sdvo (struct intel_encoder *encoder,const struct intel_crtc_state *old_crtc_state,const struct drm_connector_state *conn_state)
@@ -1656,6 +1689,9 @@ static void intel_disable_sdvo(struct intel_encoder *encoder,struct intel_crtc *crtc =to_intel_crtc (old_crtc_state->base.crtc);u32 temp; +if (old_crtc_state->has_audio) +intel_sdvo_disable_audio (intel_sdvo); +intel_sdvo_set_active_outputs (intel_sdvo,0 );if (0 ) intel_sdvo_set_encoder_power_state(intel_sdvo,
@@ -1741,6 +1777,9 @@ static void intel_enable_sdvo(struct intel_encoder *encoder,intel_sdvo_set_encoder_power_state (intel_sdvo,DRM_MODE_DPMS_ON );intel_sdvo_set_active_outputs (intel_sdvo, intel_sdvo->attached_output); + +if (pipe_config->has_audio) +intel_sdvo_enable_audio (intel_sdvo, pipe_config, conn_state); } static enum drm_mode_status
@@ -2603,7 +2642,6 @@ static bool intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device) {struct drm_encoder *encoder = &intel_sdvo->base.base; -struct drm_i915_private *dev_priv =to_i915 (encoder->dev);struct drm_connector *connector;struct intel_encoder *intel_encoder =to_intel_encoder (encoder);struct intel_connector *intel_connector;
@@ -2640,9 +2678,7 @@ intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device) encoder->encoder_type =DRM_MODE_ENCODER_TMDS ; connector->connector_type =DRM_MODE_CONNECTOR_DVID ; -/* gen3 doesn't do the hdmi bits in the SDVO register */ -if (INTEL_GEN (dev_priv) >=4 && -intel_sdvo_is_hdmi_connector (intel_sdvo, device)) { +if (intel_sdvo_is_hdmi_connector (intel_sdvo, device)) { connector->connector_type =DRM_MODE_CONNECTOR_HDMIA ; intel_sdvo_connector->is_hdmi = true; }
drivers/gpu/drm/i915/intel_sdvo_regs.h +3 -0
@@ -707,6 +707,9 @@ struct intel_sdvo_enhancements_arg {#define SDVO_CMD_GET_AUDIO_ENCRYPT_PREFER 0x90#define SDVO_CMD_SET_AUDIO_STAT 0x91#define SDVO_CMD_GET_AUDIO_STAT 0x92 +#define SDVO_AUDIO_ELD_VALID (1 << 0) +#define SDVO_AUDIO_PRESENCE_DETECT (1 << 1) +#define SDVO_AUDIO_CP_READY (1 << 2)#define SDVO_CMD_SET_HBUF_INDEX 0x93#define SDVO_HBUF_INDEX_ELD 0#define SDVO_HBUF_INDEX_AVI_IF 1