drm: stop using edid_blob_ptr in drivers
Subsystems (4)
cover drm: stop using edid_blob_ptr in drivers
Jani Nikula (6):
drm/nouveau: convert to using is_hdmi and has_audio from display info drm/radeon: convert to using is_hdmi and has_audio from display info drm/radeon: remove radeon_connector_edid() and stop using
edid_blob_ptr
drm/amdgpu: remove amdgpu_connector_edid() and stop using
edid_blob_ptr
drm/edid: add a helper for EDID sysfs property show drm/connector: update edid_blob_ptr documentation
.../gpu/drm/amd/amdgpu/amdgpu_connectors.c | 16 --------- .../gpu/drm/amd/amdgpu/amdgpu_connectors.h | 1 - drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 4 +-- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 4 +-- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 4 +-- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 4 +-- drivers/gpu/drm/drm_crtc_internal.h | 2 ++ drivers/gpu/drm/drm_edid.c | 33 +++++++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 24 ++------------ drivers/gpu/drm/nouveau/dispnv50/disp.c | 8 ++--- drivers/gpu/drm/nouveau/dispnv50/head.c | 8 +---- drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +- drivers/gpu/drm/radeon/atombios_encoders.c | 10 +++--- drivers/gpu/drm/radeon/evergreen_hdmi.c | 5 ++- drivers/gpu/drm/radeon/radeon_audio.c | 13 ++++---- drivers/gpu/drm/radeon/radeon_connectors.c | 27 ++++----------- drivers/gpu/drm/radeon/radeon_display.c | 2 +- drivers/gpu/drm/radeon/radeon_encoders.c | 4 +-- drivers/gpu/drm/radeon/radeon_mode.h | 2 -- include/drm/drm_connector.h | 6 +++- 20 files changed, 79 insertions(+), 100 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/6 drm/nouveau: convert to using is_hdmi and has_audio from display info
Prefer the parsed results for is_hdmi and has_audio in display info over calling drm_detect_hdmi_monitor() and drm_detect_monitor_audio(), respectively.
Conveniently, this also removes the need to use edid_blob_ptr.
--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 8 ++++---- drivers/gpu/drm/nouveau/dispnv50/head.c | 8 +------- drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +4 -4
@@ -750,7 +750,7 @@ nv50_audio_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,struct nouveau_encoder *nv_encoder =nouveau_encoder (encoder);struct nvif_outp *outp = &nv_encoder->outp; -if (!nv50_audio_supported (encoder) || !drm_detect_monitor_audio (nv_connector->edid)) +if (!nv50_audio_supported (encoder) || !nv_connector->base.display_info.has_audio)return ;mutex_lock (&drm->audio.lock);
@@ -1764,7 +1764,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *staif ((disp->disp->object.oclass ==GT214_DISP || disp->disp->object.oclass >=GF110_DISP ) && nv_encoder->dcb->type !=DCB_OUTPUT_LVDS && -drm_detect_monitor_audio (nv_connector->edid)) + nv_connector->base.display_info.has_audio) hda = true;if (!nvif_outp_acquired (outp))
@@ -1773,7 +1773,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *staswitch (nv_encoder->dcb->type) {case DCB_OUTPUT_TMDS :if (disp->disp->object.oclass !=NV50_DISP && -drm_detect_hdmi_monitor (nv_connector->edid)) + !nv_connector->base.display_info.is_hdmi)nv50_hdmi_enable (encoder, nv_crtc, nv_connector, state, mode, hda);if (nv_encoder->outp.or.link &1 ) {
@@ -1786,7 +1786,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *sta*/ if (mode->clock >=165000 && nv_encoder->dcb->duallink_possible && - !drm_detect_hdmi_monitor (nv_connector->edid)) + !nv_connector->base.display_info.is_hdmi) proto =NV507D_SOR_SET_CONTROL_PROTOCOL_DUAL_TMDS ; }else { proto =NV507D_SOR_SET_CONTROL_PROTOCOL_SINGLE_TMDS_B ;
drivers/gpu/drm/nouveau/dispnv50/head.c +1 -7
@@ -127,14 +127,8 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh,struct drm_display_mode *omode = &asyh->state.adjusted_mode;struct drm_display_mode *umode = &asyh->state.mode;int mode = asyc->scaler.mode; -struct edid *edid;int umode_vdisplay, omode_hdisplay, omode_vdisplay; -if (connector->edid_blob_ptr) - edid = (struct edid *)connector->edid_blob_ptr->data; -else - edid =NULL ; -if (!asyc->scaler.full) {if (mode ==DRM_MODE_SCALE_NONE ) omode = umode;
@@ -162,7 +156,7 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh,*/ if ((asyc->scaler.underscan.mode ==UNDERSCAN_ON || (asyc->scaler.underscan.mode ==UNDERSCAN_AUTO && -drm_detect_hdmi_monitor (edid)))) { + connector->display_info.is_hdmi))) {u32 bX = asyc->scaler.underscan.hborder;u32 bY = asyc->scaler.underscan.vborder;u32 r = (asyh->view.oH <<19 ) / asyh->view.oW;
drivers/gpu/drm/nouveau/nouveau_connector.c +1 -1
@@ -1034,7 +1034,7 @@ get_tmds_link_bandwidth(struct drm_connector *connector)unsigned duallink_scale = nouveau_duallink && nv_encoder->dcb->duallink_possible ?2 :1 ; -if (drm_detect_hdmi_monitor (nv_connector->edid)) { +if (nv_connector->base.display_info.is_hdmi) { info = &nv_connector->base.display_info; duallink_scale =1 ; }
Signature · 1 line
2.39.2
PATCH 2/6 drm/radeon: convert to using is_hdmi and has_audio from display info
In reply to Jani NikulaPrefer the parsed results for is_hdmi and has_audio in display info over calling drm_detect_hdmi_monitor() and drm_detect_monitor_audio(), respectively.
--- drivers/gpu/drm/radeon/atombios_encoders.c | 10 +++++----- drivers/gpu/drm/radeon/evergreen_hdmi.c | 5 ++--- drivers/gpu/drm/radeon/radeon_audio.c | 6 +++--- drivers/gpu/drm/radeon/radeon_connectors.c | 12 ++++++------ drivers/gpu/drm/radeon/radeon_display.c | 2 +- drivers/gpu/drm/radeon/radeon_encoders.c | 4 ++-- 6 files changed, 19 insertions(+), 20 deletions(-)
drivers/gpu/drm/radeon/atombios_encoders.c +5 -5
@@ -701,7 +701,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)if (radeon_connector->use_digital && (radeon_connector->audio ==RADEON_AUDIO_ENABLE ))return ATOM_ENCODER_MODE_HDMI ; -else if (drm_detect_hdmi_monitor (radeon_connector_edid (connector)) && +else if (connector->display_info.is_hdmi && (radeon_connector->audio ==RADEON_AUDIO_AUTO ))return ATOM_ENCODER_MODE_HDMI ;else if (radeon_connector->use_digital)
@@ -720,7 +720,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)if (radeon_audio !=0 ) {if (radeon_connector->audio ==RADEON_AUDIO_ENABLE )return ATOM_ENCODER_MODE_HDMI ; -else if (drm_detect_hdmi_monitor (radeon_connector_edid (connector)) && +else if (connector->display_info.is_hdmi && (radeon_connector->audio ==RADEON_AUDIO_AUTO ))return ATOM_ENCODER_MODE_HDMI ;else
@@ -737,14 +737,14 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)if ((dig_connector->dp_sink_type ==CONNECTOR_OBJECT_ID_DISPLAYPORT ) || (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) {if (radeon_audio !=0 && -drm_detect_monitor_audio (radeon_connector_edid (connector)) && + connector->display_info.has_audio &&ASIC_IS_DCE4 (rdev) && !ASIC_IS_DCE5 (rdev))return ATOM_ENCODER_MODE_DP_AUDIO ;return ATOM_ENCODER_MODE_DP ; }else if (radeon_audio !=0 ) {if (radeon_connector->audio ==RADEON_AUDIO_ENABLE )return ATOM_ENCODER_MODE_HDMI ; -else if (drm_detect_hdmi_monitor (radeon_connector_edid (connector)) && +else if (connector->display_info.is_hdmi && (radeon_connector->audio ==RADEON_AUDIO_AUTO ))return ATOM_ENCODER_MODE_HDMI ;else
@@ -755,7 +755,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)break ;case DRM_MODE_CONNECTOR_eDP:if (radeon_audio !=0 && -drm_detect_monitor_audio (radeon_connector_edid (connector)) && + connector->display_info.has_audio &&ASIC_IS_DCE4 (rdev) && !ASIC_IS_DCE5 (rdev))return ATOM_ENCODER_MODE_DP_AUDIO ;return ATOM_ENCODER_MODE_DP ;
drivers/gpu/drm/radeon/evergreen_hdmi.c +2 -3
@@ -412,7 +412,7 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable)if (enable) {struct drm_connector *connector =radeon_get_connector_for_encoder (encoder); -if (connector &&drm_detect_monitor_audio (radeon_connector_edid (connector))) { +if (connector && connector->display_info.has_audio) { WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset, HDMI_AVI_INFO_SEND | /* enable AVI info frames */ HDMI_AVI_INFO_CONT | /* required for audio info values to be updated */
@@ -450,8 +450,7 @@ void evergreen_dp_enable(struct drm_encoder *encoder, bool enable)if (!dig || !dig->afmt)return ; -if (enable && connector && -drm_detect_monitor_audio (radeon_connector_edid (connector))) { +if (enable && connector && connector->display_info.has_audio) {struct drm_connector *connector =radeon_get_connector_for_encoder (encoder);struct radeon_connector *radeon_connector =to_radeon_connector (connector);struct radeon_connector_atom_dig *dig_connector;
drivers/gpu/drm/radeon/radeon_audio.c +3 -3
@@ -410,7 +410,7 @@ void radeon_audio_detect(struct drm_connector *connector, radeon_encoder->audio = rdev->audio.hdmi_funcs; } -if (drm_detect_monitor_audio (radeon_connector_edid (connector))) { +if (connector->display_info.has_audio) {if (!dig->pin) dig->pin =radeon_audio_get_pin (encoder);radeon_audio_enable (rdev, dig->pin,0xf );
@@ -647,7 +647,7 @@ static void radeon_audio_hdmi_mode_set(struct drm_encoder *encoder,if (!connector)return ; -if (drm_detect_monitor_audio (radeon_connector_edid (connector))) { +if (connector->display_info.has_audio) {radeon_audio_set_mute (encoder, true);radeon_audio_write_speaker_allocation (encoder);
@@ -687,7 +687,7 @@ static void radeon_audio_dp_mode_set(struct drm_encoder *encoder,if (!connector)return ; -if (drm_detect_monitor_audio (radeon_connector_edid (connector))) { +if (connector->display_info.has_audio) {radeon_audio_write_speaker_allocation (encoder);radeon_audio_write_sad_regs (encoder);radeon_audio_write_latency_fields (encoder, mode);
drivers/gpu/drm/radeon/radeon_connectors.c +6 -6
@@ -109,7 +109,7 @@ int radeon_get_monitor_bpc(struct drm_connector *connector)case DRM_MODE_CONNECTOR_DVII :case DRM_MODE_CONNECTOR_HDMIB :if (radeon_connector->use_digital) { -if (drm_detect_hdmi_monitor (radeon_connector_edid (connector))) { +if (connector->display_info.is_hdmi) {if (connector->display_info.bpc) bpc = connector->display_info.bpc; }
@@ -117,7 +117,7 @@ int radeon_get_monitor_bpc(struct drm_connector *connector)break ;case DRM_MODE_CONNECTOR_DVID :case DRM_MODE_CONNECTOR_HDMIA : -if (drm_detect_hdmi_monitor (radeon_connector_edid (connector))) { +if (connector->display_info.is_hdmi) {if (connector->display_info.bpc) bpc = connector->display_info.bpc; }
@@ -126,7 +126,7 @@ int radeon_get_monitor_bpc(struct drm_connector *connector) dig_connector = radeon_connector->con_priv;if ((dig_connector->dp_sink_type ==CONNECTOR_OBJECT_ID_DISPLAYPORT ) || (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP) || -drm_detect_hdmi_monitor (radeon_connector_edid (connector))) { + connector->display_info.is_hdmi) {if (connector->display_info.bpc) bpc = connector->display_info.bpc; }
@@ -150,7 +150,7 @@ int radeon_get_monitor_bpc(struct drm_connector *connector)break ; } -if (drm_detect_hdmi_monitor (radeon_connector_edid (connector))) { +if (connector->display_info.is_hdmi) {/* hdmi deep color only implemented on DCE4+ */ if ((bpc >8 ) && !ASIC_IS_DCE4 (rdev)) { DRM_DEBUG("%s: HDMI deep color %d bpc unsupported. Using 8 bpc.\n",
@@ -1478,7 +1478,7 @@ static enum drm_mode_status radeon_dvi_mode_valid(struct drm_connector *connecto (radeon_connector->connector_object_id ==CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D ) || (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B)) return MODE_OK; - else if (ASIC_IS_DCE6(rdev) && drm_detect_hdmi_monitor(radeon_connector_edid(connector))) { + else if (ASIC_IS_DCE6(rdev) && connector->display_info.is_hdmi) {/* HDMI 1.3+ supports max clock of 340 Mhz */ if (mode->clock >340000 )return MODE_CLOCK_HIGH ;
@@ -1774,7 +1774,7 @@ static enum drm_mode_status radeon_dp_mode_valid(struct drm_connector *connector (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) { return radeon_dp_mode_valid_helper(connector, mode); } else { -if (ASIC_IS_DCE6 (rdev) &&drm_detect_hdmi_monitor (radeon_connector_edid (connector))) { +if (ASIC_IS_DCE6 (rdev) && connector->display_info.is_hdmi) {/* HDMI 1.3+ supports max clock of 340 Mhz */ if (mode->clock >340000 )return MODE_CLOCK_HIGH ;
drivers/gpu/drm/radeon/radeon_display.c +1 -1
@@ -1728,7 +1728,7 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc, (!(mode->flags &DRM_MODE_FLAG_INTERLACE )) && ((radeon_encoder->underscan_type ==UNDERSCAN_ON ) || ((radeon_encoder->underscan_type ==UNDERSCAN_AUTO ) && -drm_detect_hdmi_monitor (radeon_connector_edid (connector)) && + connector->display_info.is_hdmi && is_hdtv_mode(mode)))) { if (radeon_encoder->underscan_hborder != 0) radeon_crtc->h_border = radeon_encoder->underscan_hborder;
drivers/gpu/drm/radeon/radeon_encoders.c +2 -2
@@ -386,7 +386,7 @@ bool radeon_dig_monitor_is_duallink(struct drm_encoder *encoder,case DRM_MODE_CONNECTOR_HDMIB :if (radeon_connector->use_digital) {/* HDMI 1.3 supports up to 340 Mhz over single link */ -if (ASIC_IS_DCE6 (rdev) &&drm_detect_hdmi_monitor (radeon_connector_edid (connector))) { +if (ASIC_IS_DCE6 (rdev) && connector->display_info.is_hdmi) {if (pixel_clock >340000 )return true;else
@@ -408,7 +408,7 @@ bool radeon_dig_monitor_is_duallink(struct drm_encoder *encoder,return false; else {/* HDMI 1.3 supports up to 340 Mhz over single link */ -if (ASIC_IS_DCE6 (rdev) &&drm_detect_hdmi_monitor (radeon_connector_edid (connector))) { +if (ASIC_IS_DCE6 (rdev) && connector->display_info.is_hdmi) {if (pixel_clock >340000 )return true;else
Signature · 1 line
2.39.2
PATCH 3/6 drm/radeon: remove radeon_connector_edid() and stop using edid_blob_ptr
In reply to Jani Nikularadeon_connector_edid() copies the EDID from edid_blob_ptr as a side effect if radeon_connector->edid isn't initialized. However, everywhere that the returned EDID is used, the EDID should have been set beforehands.
Only the drm EDID code should look at the EDID property, anyway, so stop using it.
--- drivers/gpu/drm/radeon/radeon_audio.c | 7 ++++--- drivers/gpu/drm/radeon/radeon_connectors.c | 15 --------------- drivers/gpu/drm/radeon/radeon_mode.h | 2 -- 3 files changed, 4 insertions(+), 20 deletions(-)
drivers/gpu/drm/radeon/radeon_audio.c +4 -3
@@ -304,6 +304,7 @@ void radeon_audio_endpoint_wreg(struct radeon_device *rdev, u32 offset,static void radeon_audio_write_sad_regs (struct drm_encoder *encoder) {struct drm_connector *connector =radeon_get_connector_for_encoder (encoder); +struct radeon_connector *radeon_connector =to_radeon_connector (connector);struct radeon_encoder *radeon_encoder =to_radeon_encoder (encoder);struct cea_sad *sads;int sad_count;
@@ -311,7 +312,7 @@ static void radeon_audio_write_sad_regs(struct drm_encoder *encoder)if (!connector)return ; - sad_count =drm_edid_to_sad (radeon_connector_edid (connector), &sads); + sad_count =drm_edid_to_sad (radeon_connector->edid, &sads);if (sad_count <0 )DRM_ERROR ("Couldn't read SADs: %d\n" , sad_count);if (sad_count <=0 )
@@ -327,6 +328,7 @@ static void radeon_audio_write_sad_regs(struct drm_encoder *encoder)static void radeon_audio_write_speaker_allocation (struct drm_encoder *encoder) {struct drm_connector *connector =radeon_get_connector_for_encoder (encoder); +struct radeon_connector *radeon_connector =to_radeon_connector (connector);struct radeon_encoder *radeon_encoder =to_radeon_encoder (encoder);u8 *sadb =NULL ;int sad_count;
@@ -334,8 +336,7 @@ static void radeon_audio_write_speaker_allocation(struct drm_encoder *encoder)if (!connector)return ; - sad_count =drm_edid_to_speaker_allocation (radeon_connector_edid (connector), - &sadb); + sad_count =drm_edid_to_speaker_allocation (radeon_connector->edid, &sadb);if (sad_count <0 ) {DRM_DEBUG ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count);
drivers/gpu/drm/radeon/radeon_connectors.c +0 -15
@@ -255,21 +255,6 @@ static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector,return NULL ; } -struct edid *radeon_connector_edid (struct drm_connector *connector) -{ -struct radeon_connector *radeon_connector =to_radeon_connector (connector); -struct drm_property_blob *edid_blob = connector->edid_blob_ptr; - -if (radeon_connector->edid) { -return radeon_connector->edid; - }else if (edid_blob) { -struct edid *edid =kmemdup (edid_blob->data, edid_blob->length,GFP_KERNEL ); -if (edid) - radeon_connector->edid = edid; - } -return radeon_connector->edid; -} -static void radeon_connector_get_edid (struct drm_connector *connector) {struct drm_device *dev = connector->dev;
drivers/gpu/drm/radeon/radeon_mode.h +0 -2
@@ -704,8 +704,6 @@ extern u16 radeon_connector_encoder_get_dp_bridge_encoder_id(struct drm_connectoextern bool radeon_connector_is_dp12_capable (struct drm_connector *connector);extern int radeon_get_monitor_bpc (struct drm_connector *connector); -extern struct edid *radeon_connector_edid (struct drm_connector *connector); -extern void radeon_connector_hotplug (struct drm_connector *connector);extern int radeon_dp_mode_valid_helper (struct drm_connector *connector,struct drm_display_mode *mode);
Signature · 1 line
2.39.2
PATCH 4/6 drm/amdgpu: remove amdgpu_connector_edid() and stop using edid_blob_ptr
In reply to Jani Nikulaamdgpu_connector_edid() copies the EDID from edid_blob_ptr as a side effect if amdgpu_connector->edid isn't initialized. However, everywhere that the returned EDID is used, the EDID should have been set beforehands.
Only the drm EDID code should look at the EDID property, anyway, so stop using it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 16 ---------------- drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.h | 1 - drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 4 ++-- 6 files changed, 8 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +0 -16
@@ -246,22 +246,6 @@ amdgpu_connector_find_encoder(struct drm_connector *connector,return NULL ; } -struct edid *amdgpu_connector_edid (struct drm_connector *connector) -{ -struct amdgpu_connector *amdgpu_connector =to_amdgpu_connector (connector); -struct drm_property_blob *edid_blob = connector->edid_blob_ptr; - -if (amdgpu_connector->edid) { -return amdgpu_connector->edid; - }else if (edid_blob) { -struct edid *edid =kmemdup (edid_blob->data, edid_blob->length,GFP_KERNEL ); - -if (edid) - amdgpu_connector->edid = edid; - } -return amdgpu_connector->edid; -} -static struct edid *amdgpu_connector_get_hardcoded_edid (struct amdgpu_device *adev) {
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.h +0 -1
@@ -24,7 +24,6 @@#ifndef __AMDGPU_CONNECTORS_H__#define __AMDGPU_CONNECTORS_H__ -struct edid *amdgpu_connector_edid (struct drm_connector *connector);void amdgpu_connector_hotplug (struct drm_connector *connector);int amdgpu_connector_get_monitor_bpc (struct drm_connector *connector);u16 amdgpu_connector_encoder_get_dp_bridge_encoder_id (struct drm_connector *connector);
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +2 -2
@@ -1297,7 +1297,7 @@ static void dce_v10_0_audio_write_speaker_allocation(struct drm_encoder *encoderreturn ; } - sad_count =drm_edid_to_speaker_allocation (amdgpu_connector_edid (connector), &sadb); + sad_count =drm_edid_to_speaker_allocation (amdgpu_connector->edid, &sadb);if (sad_count <0 ) {DRM_ERROR ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count); sad_count =0 ;
@@ -1367,7 +1367,7 @@ static void dce_v10_0_audio_write_sad_regs(struct drm_encoder *encoder)return ; } - sad_count =drm_edid_to_sad (amdgpu_connector_edid (connector), &sads); + sad_count =drm_edid_to_sad (amdgpu_connector->edid, &sads);if (sad_count <0 )DRM_ERROR ("Couldn't read SADs: %d\n" , sad_count);if (sad_count <=0 )
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +2 -2
@@ -1329,7 +1329,7 @@ static void dce_v11_0_audio_write_speaker_allocation(struct drm_encoder *encoderreturn ; } - sad_count =drm_edid_to_speaker_allocation (amdgpu_connector_edid (connector), &sadb); + sad_count =drm_edid_to_speaker_allocation (amdgpu_connector->edid, &sadb);if (sad_count <0 ) {DRM_ERROR ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count); sad_count =0 ;
@@ -1399,7 +1399,7 @@ static void dce_v11_0_audio_write_sad_regs(struct drm_encoder *encoder)return ; } - sad_count =drm_edid_to_sad (amdgpu_connector_edid (connector), &sads); + sad_count =drm_edid_to_sad (amdgpu_connector->edid, &sads);if (sad_count <0 )DRM_ERROR ("Couldn't read SADs: %d\n" , sad_count);if (sad_count <=0 )
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2 -2
@@ -1201,7 +1201,7 @@ static void dce_v6_0_audio_write_speaker_allocation(struct drm_encoder *encoder)return ; } - sad_count =drm_edid_to_speaker_allocation (amdgpu_connector_edid (connector), &sadb); + sad_count =drm_edid_to_speaker_allocation (amdgpu_connector->edid, &sadb);if (sad_count <0 ) {DRM_ERROR ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count); sad_count =0 ;
@@ -1276,7 +1276,7 @@ static void dce_v6_0_audio_write_sad_regs(struct drm_encoder *encoder)return ; } - sad_count =drm_edid_to_sad (amdgpu_connector_edid (connector), &sads); + sad_count =drm_edid_to_sad (amdgpu_connector->edid, &sads);if (sad_count <0 )DRM_ERROR ("Couldn't read SADs: %d\n" , sad_count);if (sad_count <=0 )
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +2 -2
@@ -1256,7 +1256,7 @@ static void dce_v8_0_audio_write_speaker_allocation(struct drm_encoder *encoder)return ; } - sad_count =drm_edid_to_speaker_allocation (amdgpu_connector_edid (connector), &sadb); + sad_count =drm_edid_to_speaker_allocation (amdgpu_connector->edid, &sadb);if (sad_count <0 ) {DRM_ERROR ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count); sad_count =0 ;
@@ -1324,7 +1324,7 @@ static void dce_v8_0_audio_write_sad_regs(struct drm_encoder *encoder)return ; } - sad_count =drm_edid_to_sad (amdgpu_connector_edid (connector), &sads); + sad_count =drm_edid_to_sad (amdgpu_connector->edid, &sads);if (sad_count <0 )DRM_ERROR ("Couldn't read SADs: %d\n" , sad_count);if (sad_count <=0 )
Signature · 1 line
2.39.2
PATCH 5/6 drm/edid: add a helper for EDID sysfs property show
In reply to Jani NikulaAdd a helper to get the EDID property for sysfs property show. This hides all the edid_blob_ptr usage within drm_edid.c.
--- drivers/gpu/drm/drm_crtc_internal.h | 2 ++ drivers/gpu/drm/drm_edid.c | 33 +++++++++++++++++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 24 ++------------------- 3 files changed, 37 insertions(+), 22 deletions(-)
drivers/gpu/drm/drm_crtc_internal.h +2 -0
@@ -292,6 +292,8 @@ void drm_mode_fixup_1366x768(struct drm_display_mode *mode);int drm_edid_override_show (struct drm_connector *connector,struct seq_file *m);int drm_edid_override_set (struct drm_connector *connector,const void *edid,size_t size);int drm_edid_override_reset (struct drm_connector *connector); +ssize_t drm_edid_connector_property_show (struct drm_connector *connector, +char *buf,loff_t off,size_t count);/* drm_edid_load.c */ #ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE
drivers/gpu/drm/drm_edid.c +33 -0
@@ -6831,6 +6831,39 @@ static int _drm_edid_connector_property_update(struct drm_connector *connector,return ret; } +/* For sysfs edid show implementation */ +ssize_t drm_edid_connector_property_show (struct drm_connector *connector, +char *buf,loff_t off,size_t count) +{ +const void *edid; +size_t size; +ssize_t ret =0 ; + +mutex_lock (&connector->dev->mode_config.mutex); + +if (!connector->edid_blob_ptr) + goto unlock; + + edid = connector->edid_blob_ptr->data; + size = connector->edid_blob_ptr->length; +if (!edid) + goto unlock; + +if (off >= size) + goto unlock; + +if (off + count > size) + count = size - off; + +memcpy (buf, edid + off, count); + + ret = count; +unlock: +mutex_unlock (&connector->dev->mode_config.mutex); + +return ret; +} +/** * drm_edid_connector_update - Update connector information from EDID * @connector: Connector
drivers/gpu/drm/drm_sysfs.c +2 -22
@@ -267,29 +267,9 @@ static ssize_t edid_show(struct file *filp, struct kobject *kobj, {struct device *connector_dev =kobj_to_dev (kobj);struct drm_connector *connector =to_drm_connector (connector_dev); -unsigned char *edid; -size_t size; -ssize_t ret =0 ; +ssize_t ret; -mutex_lock (&connector->dev->mode_config.mutex); -if (!connector->edid_blob_ptr) - goto unlock; - - edid = connector->edid_blob_ptr->data; - size = connector->edid_blob_ptr->length; -if (!edid) - goto unlock; - -if (off >= size) - goto unlock; - -if (off + count > size) - count = size - off; -memcpy (buf, edid + off, count); - - ret = count; -unlock: -mutex_unlock (&connector->dev->mode_config.mutex); + ret =drm_edid_connector_property_show (connector, buf, off, count);return ret; }
Signature · 1 line
2.39.2
PATCH 6/6 drm/connector: update edid_blob_ptr documentation
In reply to Jani NikulaAccessing the EDID via edid_blob_ptr causes chicken-and-egg problems. Keep edid_blob_ptr as the userspace interface that should be accessed via dedicated functions.
--- include/drm/drm_connector.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/drm/drm_connector.h +5 -1
@@ -1636,8 +1636,12 @@ struct drm_connector {/** * @edid_blob_ptr: DRM property containing EDID if present. Protected by -* &drm_mode_config.mutex. This should be updated only by calling +* &drm_mode_config.mutex. +* +* This must be updated only by calling drm_edid_connector_update() or * drm_connector_update_edid_property(). +* +* This must not be used by drivers directly. */ struct drm_property_blob *edid_blob_ptr;
Signature · 1 line
2.39.2
Re: [PATCH 1/6] drm/nouveau: convert to using is_hdmi and has_audio from display info
In reply to Jani NikulaQuoted 41 lines · Jani Nikula
Prefer the parsed results for
is_hdmiandhas_audioin display info over callingdrm_detect_hdmi_monitor()anddrm_detect_monitor_audio(), respectively.Conveniently, this also removes the need to use
edid_blob_ptr.Cc Karol Herbst <[email protected]>Cc Lyude Paul <[email protected]>Cc Danilo Krummrich <[email protected]>Signed-off-by Jani Nikula <[email protected]>--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 8 ++++---- drivers/gpu/drm/nouveau/dispnv50/head.c | 8 +------- drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-)drivers/gpu/drm/nouveau/dispnv50/disp.c +2
-2@@ -750,7 +750,7 @@ nv50_audio_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,struct nouveau_encoder *nv_encoder =nouveau_encoder (encoder);struct nvif_outp *outp = &nv_encoder->outp; -if (!nv50_audio_supported (encoder) || !drm_detect_monitor_audio (nv_connector->edid)) +if (!nv50_audio_supported (encoder) || !nv_connector->base.display_info.has_audio)return ;mutex_lock (&drm->audio.lock);@@ -1764,7 +1764,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *staif ((disp->disp->object.oclass ==GT214_DISP || disp->disp->object.oclass >=GF110_DISP ) && nv_encoder->dcb->type !=DCB_OUTPUT_LVDS && -drm_detect_monitor_audio (nv_connector->edid)) + nv_connector->base.display_info.has_audio) hda = true;if (!nvif_outp_acquired (outp))
drivers/gpu/drm/nouveau/dispnv50/disp.c nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *sta · line 1776
Quoted 5 lines
drivers/gpu/drm/nouveau/dispnv50/disp.c +1
-1@@ -1773,7 +1773,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *staswitch (nv_encoder->dcb->type) {case DCB_OUTPUT_TMDS :if (disp->disp->object.oclass !=NV50_DISP && -drm_detect_hdmi_monitor (nv_connector->edid)) + !nv_connector->base.display_info.is_hdmi)
This is backwards, no?
Quoted 56 lines
drivers/gpu/drm/nouveau/dispnv50/disp.c +1
-1nv50_hdmi_enable (encoder, nv_crtc, nv_connector, state, mode, hda);if (nv_encoder->outp.or.link &1 ) {@@ -1786,7 +1786,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *sta*/ if (mode->clock >=165000 && nv_encoder->dcb->duallink_possible && - !drm_detect_hdmi_monitor (nv_connector->edid)) + !nv_connector->base.display_info.is_hdmi) proto =NV507D_SOR_SET_CONTROL_PROTOCOL_DUAL_TMDS ; }else { proto =NV507D_SOR_SET_CONTROL_PROTOCOL_SINGLE_TMDS_B ;drivers/gpu/drm/nouveau/dispnv50/head.c +1
-7@@ -127,14 +127,8 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh,struct drm_display_mode *omode = &asyh->state.adjusted_mode;struct drm_display_mode *umode = &asyh->state.mode;int mode = asyc->scaler.mode; -struct edid *edid;int umode_vdisplay, omode_hdisplay, omode_vdisplay; -if (connector->edid_blob_ptr) - edid = (struct edid *)connector->edid_blob_ptr->data; -else - edid =NULL ; -if (!asyc->scaler.full) {if (mode ==DRM_MODE_SCALE_NONE ) omode = umode;@@ -162,7 +156,7 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh,*/ if ((asyc->scaler.underscan.mode ==UNDERSCAN_ON || (asyc->scaler.underscan.mode ==UNDERSCAN_AUTO && -drm_detect_hdmi_monitor (edid)))) { + connector->display_info.is_hdmi))) {u32 bX = asyc->scaler.underscan.hborder;u32 bY = asyc->scaler.underscan.vborder;u32 r = (asyh->view.oH <<19 ) / asyh->view.oW;drivers/gpu/drm/nouveau/nouveau_connector.c +1
-2@@ -1034,7 +1034,7 @@ get_tmds_link_bandwidth(struct drm_connector *connector)unsigned duallink_scale = nouveau_duallink && nv_encoder->dcb->duallink_possible ?2 :1 ; -if (drm_detect_hdmi_monitor (nv_connector->edid)) { +if (nv_connector->base.display_info.is_hdmi) { info = &nv_connector->base.display_info; duallink_scale =1 ; } --2.39.2
Re: [PATCH 1/6] drm/nouveau: convert to using is_hdmi and has_audio from display info
Quoted 40 lines · Ilia Mirkin
Quoted 39 lines · Jani Nikula
Prefer the parsed results for
is_hdmiandhas_audioin display info over callingdrm_detect_hdmi_monitor()anddrm_detect_monitor_audio(), respectively.Conveniently, this also removes the need to use
edid_blob_ptr.Cc Karol Herbst <[email protected]>Cc Lyude Paul <[email protected]>Cc Danilo Krummrich <[email protected]>Signed-off-by Jani Nikula <[email protected]>--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 8 ++++---- drivers/gpu/drm/nouveau/dispnv50/head.c | 8 +------- drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-)drivers/gpu/drm/nouveau/dispnv50/disp.c +2
-2@@ -750,7 +750,7 @@ nv50_audio_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,struct nouveau_encoder *nv_encoder =nouveau_encoder (encoder);struct nvif_outp *outp = &nv_encoder->outp; -if (!nv50_audio_supported (encoder) || !drm_detect_monitor_audio (nv_connector->edid)) +if (!nv50_audio_supported (encoder) || !nv_connector->base.display_info.has_audio)return ;mutex_lock (&drm->audio.lock);@@ -1764,7 +1764,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *staif ((disp->disp->object.oclass ==GT214_DISP || disp->disp->object.oclass >=GF110_DISP ) && nv_encoder->dcb->type !=DCB_OUTPUT_LVDS && -drm_detect_monitor_audio (nv_connector->edid)) + nv_connector->base.display_info.has_audio) hda = true;
Quoted 9 lines
drivers/gpu/drm/nouveau/dispnv50/disp.c nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *sta · line 1776
Quoted 7 lines
drivers/gpu/drm/nouveau/dispnv50/disp.c +1
-1if (!nvif_outp_acquired (outp))@@ -1773,7 +1773,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *staswitch (nv_encoder->dcb->type) {case DCB_OUTPUT_TMDS :if (disp->disp->object.oclass !=NV50_DISP && -drm_detect_hdmi_monitor (nv_connector->edid)) + !nv_connector->base.display_info.is_hdmi)This is backwards, no?
Good catch, thanks!
BR,
Jani.
Quoted 57 lines
Quoted 57 lines
drivers/gpu/drm/nouveau/dispnv50/disp.c +1
-1nv50_hdmi_enable (encoder, nv_crtc, nv_connector, state, mode, hda);if (nv_encoder->outp.or.link &1 ) {@@ -1786,7 +1786,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *sta*/ if (mode->clock >=165000 && nv_encoder->dcb->duallink_possible && - !drm_detect_hdmi_monitor (nv_connector->edid)) + !nv_connector->base.display_info.is_hdmi) proto =NV507D_SOR_SET_CONTROL_PROTOCOL_DUAL_TMDS ; }else { proto =NV507D_SOR_SET_CONTROL_PROTOCOL_SINGLE_TMDS_B ;drivers/gpu/drm/nouveau/dispnv50/head.c +1
-7@@ -127,14 +127,8 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh,struct drm_display_mode *omode = &asyh->state.adjusted_mode;struct drm_display_mode *umode = &asyh->state.mode;int mode = asyc->scaler.mode; -struct edid *edid;int umode_vdisplay, omode_hdisplay, omode_vdisplay; -if (connector->edid_blob_ptr) - edid = (struct edid *)connector->edid_blob_ptr->data; -else - edid =NULL ; -if (!asyc->scaler.full) {if (mode ==DRM_MODE_SCALE_NONE ) omode = umode;@@ -162,7 +156,7 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh,*/ if ((asyc->scaler.underscan.mode ==UNDERSCAN_ON || (asyc->scaler.underscan.mode ==UNDERSCAN_AUTO && -drm_detect_hdmi_monitor (edid)))) { + connector->display_info.is_hdmi))) {u32 bX = asyc->scaler.underscan.hborder;u32 bY = asyc->scaler.underscan.vborder;u32 r = (asyh->view.oH <<19 ) / asyh->view.oW;drivers/gpu/drm/nouveau/nouveau_connector.c +1
-2@@ -1034,7 +1034,7 @@ get_tmds_link_bandwidth(struct drm_connector *connector)unsigned duallink_scale = nouveau_duallink && nv_encoder->dcb->duallink_possible ?2 :1 ; -if (drm_detect_hdmi_monitor (nv_connector->edid)) { +if (nv_connector->base.display_info.is_hdmi) { info = &nv_connector->base.display_info; duallink_scale =1 ; } --2.39.2
Signature · 1 line
Jani Nikula, Intel
PATCH v2 1/1 drm/nouveau: convert to using is_hdmi and has_audio from display info
In reply to Jani NikulaPrefer the parsed results for is_hdmi and has_audio in display info over calling drm_detect_hdmi_monitor() and drm_detect_monitor_audio(), respectively.
Conveniently, this also removes the need to use edid_blob_ptr.
v2: Reverse a backwards if condition (Ilia)
--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 8 ++++---- drivers/gpu/drm/nouveau/dispnv50/head.c | 8 +------- drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-)
drivers/gpu/drm/nouveau/dispnv50/disp.c +4 -4
@@ -750,7 +750,7 @@ nv50_audio_enable(struct drm_encoder *encoder, struct nouveau_crtc *nv_crtc,struct nouveau_encoder *nv_encoder =nouveau_encoder (encoder);struct nvif_outp *outp = &nv_encoder->outp; -if (!nv50_audio_supported (encoder) || !drm_detect_monitor_audio (nv_connector->edid)) +if (!nv50_audio_supported (encoder) || !nv_connector->base.display_info.has_audio)return ;mutex_lock (&drm->audio.lock);
@@ -1764,7 +1764,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *staif ((disp->disp->object.oclass ==GT214_DISP || disp->disp->object.oclass >=GF110_DISP ) && nv_encoder->dcb->type !=DCB_OUTPUT_LVDS && -drm_detect_monitor_audio (nv_connector->edid)) + nv_connector->base.display_info.has_audio) hda = true;if (!nvif_outp_acquired (outp))
@@ -1773,7 +1773,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *staswitch (nv_encoder->dcb->type) {case DCB_OUTPUT_TMDS :if (disp->disp->object.oclass !=NV50_DISP && -drm_detect_hdmi_monitor (nv_connector->edid)) + nv_connector->base.display_info.is_hdmi)nv50_hdmi_enable (encoder, nv_crtc, nv_connector, state, mode, hda);if (nv_encoder->outp.or.link &1 ) {
@@ -1786,7 +1786,7 @@ nv50_sor_atomic_enable(struct drm_encoder *encoder, struct drm_atomic_state *sta*/ if (mode->clock >=165000 && nv_encoder->dcb->duallink_possible && - !drm_detect_hdmi_monitor (nv_connector->edid)) + !nv_connector->base.display_info.is_hdmi) proto =NV507D_SOR_SET_CONTROL_PROTOCOL_DUAL_TMDS ; }else { proto =NV507D_SOR_SET_CONTROL_PROTOCOL_SINGLE_TMDS_B ;
drivers/gpu/drm/nouveau/dispnv50/head.c +1 -7
@@ -127,14 +127,8 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh,struct drm_display_mode *omode = &asyh->state.adjusted_mode;struct drm_display_mode *umode = &asyh->state.mode;int mode = asyc->scaler.mode; -struct edid *edid;int umode_vdisplay, omode_hdisplay, omode_vdisplay; -if (connector->edid_blob_ptr) - edid = (struct edid *)connector->edid_blob_ptr->data; -else - edid =NULL ; -if (!asyc->scaler.full) {if (mode ==DRM_MODE_SCALE_NONE ) omode = umode;
@@ -162,7 +156,7 @@ nv50_head_atomic_check_view(struct nv50_head_atom *armh,*/ if ((asyc->scaler.underscan.mode ==UNDERSCAN_ON || (asyc->scaler.underscan.mode ==UNDERSCAN_AUTO && -drm_detect_hdmi_monitor (edid)))) { + connector->display_info.is_hdmi))) {u32 bX = asyc->scaler.underscan.hborder;u32 bY = asyc->scaler.underscan.vborder;u32 r = (asyh->view.oH <<19 ) / asyh->view.oW;
drivers/gpu/drm/nouveau/nouveau_connector.c +1 -1
@@ -1034,7 +1034,7 @@ get_tmds_link_bandwidth(struct drm_connector *connector)unsigned duallink_scale = nouveau_duallink && nv_encoder->dcb->duallink_possible ?2 :1 ; -if (drm_detect_hdmi_monitor (nv_connector->edid)) { +if (nv_connector->base.display_info.is_hdmi) { info = &nv_connector->base.display_info; duallink_scale =1 ; }
Signature · 1 line
2.39.2