drm/radeon: restructure edid fetching
Subsystems (3)
PATCH 1/2 drm/radeon: restructure edid fetching
Split radeon_ddc_get_modes() and move it intoradeon_connectors.c since that is the only place
that uses it.
--- drivers/gpu/drm/radeon/radeon_connectors.c | 162 ++++++++++++++++++++--------- drivers/gpu/drm/radeon/radeon_display.c | 58 ----------- drivers/gpu/drm/radeon/radeon_mode.h | 1 - 3 files changed, 110 insertions(+), 111 deletions(-)
drivers/gpu/drm/radeon/radeon_connectors.c +110 -52
@@ -268,6 +268,79 @@ static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector,return NULL ; } +static void radeon_connector_get_edid (struct drm_connector *connector) +{ +struct drm_device *dev = connector->dev; +struct radeon_device *rdev = dev->dev_private; +struct radeon_connector *radeon_connector =to_radeon_connector (connector); + +if (radeon_connector->edid) +return ; + +/* on hw with routers, select right port */ +if (radeon_connector->router.ddc_valid) +radeon_router_select_ddc_port (radeon_connector); + +if ((radeon_connector_encoder_get_dp_bridge_encoder_id (connector) != +ENCODER_OBJECT_ID_NONE ) && + radeon_connector->ddc_bus->has_aux) { + radeon_connector->edid =drm_get_edid (connector, + &radeon_connector->ddc_bus->aux.ddc); + }else if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) || + (connector->connector_type == DRM_MODE_CONNECTOR_eDP)) { +struct radeon_connector_atom_dig *dig = radeon_connector->con_priv; + +if ((dig->dp_sink_type ==CONNECTOR_OBJECT_ID_DISPLAYPORT || + dig->dp_sink_type == CONNECTOR_OBJECT_ID_eDP) && + radeon_connector->ddc_bus->has_aux) + radeon_connector->edid =drm_get_edid (&radeon_connector->base, + &radeon_connector->ddc_bus->aux.ddc); +else if (radeon_connector->ddc_bus) + radeon_connector->edid =drm_get_edid (&radeon_connector->base, + &radeon_connector->ddc_bus->adapter); + }else if (radeon_connector->ddc_bus) { + radeon_connector->edid =drm_get_edid (&radeon_connector->base, + &radeon_connector->ddc_bus->adapter); + } + +if (!radeon_connector->edid) { +if (rdev->is_atom_bios) { +/* some laptops provide a hardcoded edid in rom for LCDs */ +if (((connector->connector_type ==DRM_MODE_CONNECTOR_LVDS ) || + (connector->connector_type == DRM_MODE_CONNECTOR_eDP))) + radeon_connector->edid =radeon_bios_get_hardcoded_edid (rdev); + }else { +/* some servers provide a hardcoded edid in rom for KVMs */ + radeon_connector->edid =radeon_bios_get_hardcoded_edid (rdev); + } + } +} + +static void radeon_connector_free_edid (struct drm_connector *connector) +{ +struct radeon_connector *radeon_connector =to_radeon_connector (connector); + +if (radeon_connector->edid) { +kfree (radeon_connector->edid); + radeon_connector->edid =NULL ; + } +} + +static int radeon_ddc_get_modes (struct drm_connector *connector) +{ +struct radeon_connector *radeon_connector =to_radeon_connector (connector); +int ret; + +if (radeon_connector->edid) { +drm_mode_connector_update_edid_property (connector, radeon_connector->edid); + ret =drm_add_edid_modes (connector, radeon_connector->edid); +drm_edid_to_eld (connector, radeon_connector->edid); +return ret; + } +drm_mode_connector_update_edid_property (connector,NULL ); +return 0 ; +} +static struct drm_encoder *radeon_best_single_encoder (struct drm_connector *connector) {int enc_id = connector->encoder_ids[0 ];
@@ -675,22 +748,20 @@ static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,static int radeon_lvds_get_modes (struct drm_connector *connector) { -struct radeon_connector *radeon_connector =to_radeon_connector (connector);struct drm_encoder *encoder;int ret =0 ;struct drm_display_mode *mode; -if (radeon_connector->ddc_bus) { - ret =radeon_ddc_get_modes (radeon_connector); -if (ret >0 ) { - encoder =radeon_best_single_encoder (connector); -if (encoder) { -radeon_fixup_lvds_native_mode (encoder, connector); -/* add scaled modes */ -radeon_add_common_modes (encoder, connector); - } -return ret; +radeon_connector_get_edid (connector); + ret =radeon_ddc_get_modes (connector); +if (ret >0 ) { + encoder =radeon_best_single_encoder (connector); +if (encoder) { +radeon_fixup_lvds_native_mode (encoder, connector); +/* add scaled modes */ +radeon_add_common_modes (encoder, connector); } +return ret; } encoder =radeon_best_single_encoder (connector);
@@ -765,16 +836,9 @@ radeon_lvds_detect(struct drm_connector *connector, bool force) }/* check for edid as well */ +radeon_connector_get_edid (connector);if (radeon_connector->edid) ret = connector_status_connected; -else { -if (radeon_connector->ddc_bus) { - radeon_connector->edid =drm_get_edid (&radeon_connector->base, - &radeon_connector->ddc_bus->adapter); -if (radeon_connector->edid) - ret = connector_status_connected; - } - }/* check acpi lid status ??? */ radeon_connector_update_scratch_regs (connector, ret);
@@ -787,8 +851,7 @@ static void radeon_connector_destroy(struct drm_connector *connector) {struct radeon_connector *radeon_connector =to_radeon_connector (connector); -if (radeon_connector->edid) -kfree (radeon_connector->edid); +radeon_connector_free_edid (connector);kfree (radeon_connector->con_priv);drm_connector_unregister (connector);drm_connector_cleanup (connector);
@@ -847,10 +910,10 @@ static const struct drm_connector_funcs radeon_lvds_connector_funcs = {static int radeon_vga_get_modes (struct drm_connector *connector) { -struct radeon_connector *radeon_connector =to_radeon_connector (connector);int ret; - ret =radeon_ddc_get_modes (radeon_connector); +radeon_connector_get_edid (connector); + ret =radeon_ddc_get_modes (connector);radeon_get_native_mode (connector);
@@ -895,28 +958,26 @@ radeon_vga_detect(struct drm_connector *connector, bool force) dret =radeon_ddc_probe (radeon_connector, false);if (dret) { radeon_connector->detected_by_load = false; -if (radeon_connector->edid) { -kfree (radeon_connector->edid); - radeon_connector->edid =NULL ; - } - radeon_connector->edid =drm_get_edid (&radeon_connector->base, &radeon_connector->ddc_bus->adapter); +radeon_connector_free_edid (connector); +radeon_connector_get_edid (connector);if (!radeon_connector->edid) {DRM_ERROR ("%s: probed a monitor but no|invalid EDID\n" , connector->name); ret = connector_status_connected; }else { - radeon_connector->use_digital = !!(radeon_connector->edid->input &DRM_EDID_INPUT_DIGITAL ); + radeon_connector->use_digital = + !!(radeon_connector->edid->input &DRM_EDID_INPUT_DIGITAL );/* some oems have boards with separate digital and analog connectors * with a shared ddc line (often vga + hdmi) */ if (radeon_connector->use_digital && radeon_connector->shared_ddc) { -kfree (radeon_connector->edid); - radeon_connector->edid =NULL ; +radeon_connector_free_edid (connector); ret = connector_status_disconnected; - }else + }else { ret = connector_status_connected; + } } }else {
@@ -1109,18 +1170,16 @@ radeon_dvi_detect(struct drm_connector *connector, bool force) dret =radeon_ddc_probe (radeon_connector, false);if (dret) { radeon_connector->detected_by_load = false; -if (radeon_connector->edid) { -kfree (radeon_connector->edid); - radeon_connector->edid =NULL ; - } - radeon_connector->edid =drm_get_edid (&radeon_connector->base, &radeon_connector->ddc_bus->adapter); +radeon_connector_free_edid (connector); +radeon_connector_get_edid (connector);if (!radeon_connector->edid) {DRM_ERROR ("%s: probed a monitor but no|invalid EDID\n" , connector->name);/* rs690 seems to have a problem with connectors not existing and always * return a block of 0's. If we see this just stop polling on this output */ -if ((rdev->family ==CHIP_RS690 || rdev->family ==CHIP_RS740 ) && radeon_connector->base.null_edid_counter) { +if ((rdev->family ==CHIP_RS690 || rdev->family ==CHIP_RS740 ) && + radeon_connector->base.null_edid_counter) { ret = connector_status_disconnected;DRM_ERROR ("%s: detected RS690 floating bus bug, stopping ddc detect\n" , connector->name);
@@ -1130,18 +1189,18 @@ radeon_dvi_detect(struct drm_connector *connector, bool force) broken_edid = true;/* defer use_digital to later */ } }else { - radeon_connector->use_digital = !!(radeon_connector->edid->input &DRM_EDID_INPUT_DIGITAL ); + radeon_connector->use_digital = + !!(radeon_connector->edid->input &DRM_EDID_INPUT_DIGITAL );/* some oems have boards with separate digital and analog connectors * with a shared ddc line (often vga + hdmi) */ if ((!radeon_connector->use_digital) && radeon_connector->shared_ddc) { -kfree (radeon_connector->edid); - radeon_connector->edid =NULL ; +radeon_connector_free_edid (connector); ret = connector_status_disconnected; - }else + }else { ret = connector_status_connected; - + }/* This gets complicated. We have boards with VGA + HDMI with a * shared DDC line and we have boards with DVI-D + HDMI with a shared * DDC line. The latter is more complex because with DVI<->HDMI adapters
@@ -1161,8 +1220,7 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)if (list_connector->connector_type !=DRM_MODE_CONNECTOR_VGA ) {/* hpd is our only option in this case */ if (!radeon_hpd_sense (rdev, radeon_connector->hpd.hpd)) { -kfree (radeon_connector->edid); - radeon_connector->edid =NULL ; +radeon_connector_free_edid (connector); ret = connector_status_disconnected; } }
@@ -1382,7 +1440,8 @@ static int radeon_dp_get_modes(struct drm_connector *connector)if (!radeon_dig_connector->edp_on)atombios_set_edp_panel_power (connector,ATOM_TRANSMITTER_ACTION_POWER_ON ); - ret =radeon_ddc_get_modes (radeon_connector); +radeon_connector_get_edid (connector); + ret =radeon_ddc_get_modes (connector);if (!radeon_dig_connector->edp_on)atombios_set_edp_panel_power (connector,ATOM_TRANSMITTER_ACTION_POWER_OFF );
@@ -1393,7 +1452,8 @@ static int radeon_dp_get_modes(struct drm_connector *connector)if (encoder)radeon_atom_ext_encoder_setup_ddc (encoder); } - ret =radeon_ddc_get_modes (radeon_connector); +radeon_connector_get_edid (connector); + ret =radeon_ddc_get_modes (connector); }if (ret >0 ) {
@@ -1426,7 +1486,8 @@ static int radeon_dp_get_modes(struct drm_connector *connector)if (encoder)radeon_atom_ext_encoder_setup_ddc (encoder); } - ret =radeon_ddc_get_modes (radeon_connector); +radeon_connector_get_edid (connector); + ret =radeon_ddc_get_modes (connector);radeon_get_native_mode (connector); }
@@ -1523,10 +1584,7 @@ radeon_dp_detect(struct drm_connector *connector, bool force) goto out; } -if (radeon_connector->edid) { -kfree (radeon_connector->edid); - radeon_connector->edid =NULL ; - } +radeon_connector_free_edid (connector);if ((connector->connector_type == DRM_MODE_CONNECTOR_eDP) || (connector->connector_type ==DRM_MODE_CONNECTOR_LVDS )) {
drivers/gpu/drm/radeon/radeon_display.c +0 -58
64 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_mode.h +0 -1
@@ -738,7 +738,6 @@ extern void radeon_i2c_put_byte(struct radeon_i2c_chan *i2c,extern void radeon_router_select_ddc_port (struct radeon_connector *radeon_connector);extern void radeon_router_select_cd_port (struct radeon_connector *radeon_connector);extern bool radeon_ddc_probe (struct radeon_connector *radeon_connector,bool use_aux); -extern int radeon_ddc_get_modes (struct radeon_connector *radeon_connector);extern struct drm_encoder *radeon_best_encoder (struct drm_connector *connector);
Signature · 1 line
1.8.3.1
PATCH 2/2 drm/radeon: use a fetch function to get the edid
We keep a cached version of the edid in radeon_connector which we use for determining connectedness and when to enable certain features like hdmi audio, etc. When the user uses the firmware interface to override the driver with some other edid the driver's copy is never updated. The fetch function will check if there is a user supplied edid and update the driver's copy if there is.
bug:
https://bugs.freedesktop.org/show_bug.cgi?id=80691
--- drivers/gpu/drm/radeon/atombios_encoders.c | 6 +++--- drivers/gpu/drm/radeon/dce6_afmt.c | 4 ++-- drivers/gpu/drm/radeon/evergreen_hdmi.c | 4 ++-- 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 ++ 7 files changed, 33 insertions(+), 16 deletions(-)
drivers/gpu/drm/radeon/atombios_encoders.c +3 -3
@@ -712,7 +712,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) && +else if (drm_detect_hdmi_monitor (radeon_connector_edid (connector)) && (radeon_connector->audio ==RADEON_AUDIO_AUTO ))return ATOM_ENCODER_MODE_HDMI ;else if (radeon_connector->use_digital)
@@ -731,7 +731,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) && +else if (drm_detect_hdmi_monitor (radeon_connector_edid (connector)) && (radeon_connector->audio ==RADEON_AUDIO_AUTO ))return ATOM_ENCODER_MODE_HDMI ;else
@@ -751,7 +751,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder) }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) && +else if (drm_detect_hdmi_monitor (radeon_connector_edid (connector)) && (radeon_connector->audio ==RADEON_AUDIO_AUTO ))return ATOM_ENCODER_MODE_HDMI ;else
drivers/gpu/drm/radeon/dce6_afmt.c +2 -2
@@ -175,7 +175,7 @@ void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder)return ; } - sad_count =drm_edid_to_speaker_allocation (radeon_connector->edid, &sadb); + sad_count =drm_edid_to_speaker_allocation (radeon_connector_edid (connector), &sadb);if (sad_count <=0 ) {DRM_ERROR ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count);return ;
@@ -238,7 +238,7 @@ void dce6_afmt_write_sad_regs(struct drm_encoder *encoder)return ; } - sad_count =drm_edid_to_sad (radeon_connector->edid, &sads); + sad_count =drm_edid_to_sad (radeon_connector_edid (connector), &sads);if (sad_count <=0 ) {DRM_ERROR ("Couldn't read SADs: %d\n" , sad_count);return ;
drivers/gpu/drm/radeon/evergreen_hdmi.c +2 -2
@@ -118,7 +118,7 @@ static void dce4_afmt_write_speaker_allocation(struct drm_encoder *encoder)return ; } - sad_count =drm_edid_to_speaker_allocation (radeon_connector->edid, &sadb); + sad_count =drm_edid_to_speaker_allocation (radeon_connector_edid (connector), &sadb);if (sad_count <=0 ) {DRM_ERROR ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count);return ;
@@ -173,7 +173,7 @@ static void evergreen_hdmi_write_sad_regs(struct drm_encoder *encoder)return ; } - sad_count =drm_edid_to_sad (radeon_connector->edid, &sads); + sad_count =drm_edid_to_sad (radeon_connector_edid (connector), &sads);if (sad_count <=0 ) {DRM_ERROR ("Couldn't read SADs: %d\n" , sad_count);return ;
drivers/gpu/drm/radeon/radeon_connectors.c +21 -6
@@ -107,7 +107,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)) { +if (drm_detect_hdmi_monitor (radeon_connector_edid (connector))) {if (connector->display_info.bpc) bpc = connector->display_info.bpc; }
@@ -115,7 +115,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)) { +if (drm_detect_hdmi_monitor (radeon_connector_edid (connector))) {if (connector->display_info.bpc) bpc = connector->display_info.bpc; }
@@ -124,7 +124,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)) { +drm_detect_hdmi_monitor (radeon_connector_edid (connector))) {if (connector->display_info.bpc) bpc = connector->display_info.bpc; }
@@ -148,7 +148,7 @@ int radeon_get_monitor_bpc(struct drm_connector *connector)break ; } -if (drm_detect_hdmi_monitor (radeon_connector->edid)) { +if (drm_detect_hdmi_monitor (radeon_connector_edid (connector))) {/* 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",
@@ -268,6 +268,21 @@ 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;
@@ -1392,7 +1407,7 @@ static int radeon_dvi_mode_valid(struct drm_connector *connector, (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)) { + else if (ASIC_IS_DCE6(rdev) && drm_detect_hdmi_monitor(radeon_connector_edid(connector))) {/* HDMI 1.3+ supports max clock of 340 Mhz */ if (mode->clock >340000 )return MODE_CLOCK_HIGH ;
@@ -1690,7 +1705,7 @@ static int 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)) { +if (ASIC_IS_DCE6 (rdev) &&drm_detect_hdmi_monitor (radeon_connector_edid (connector))) {/* 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
@@ -1692,7 +1692,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) && +drm_detect_hdmi_monitor (radeon_connector_edid (connector)) && 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
@@ -343,7 +343,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)) { +if (ASIC_IS_DCE6 (rdev) &&drm_detect_hdmi_monitor (radeon_connector_edid (connector))) {if (pixel_clock >340000 )return true;else
@@ -365,7 +365,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)) { +if (ASIC_IS_DCE6 (rdev) &&drm_detect_hdmi_monitor (radeon_connector_edid (connector))) {if (pixel_clock >340000 )return true;else
drivers/gpu/drm/radeon/radeon_mode.h +2 -0
@@ -689,6 +689,8 @@ extern bool radeon_connector_encoder_is_hbr2(struct drm_connector *connector);extern 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
1.8.3.1
Re: [PATCH 2/2] drm/radeon: use a fetch function to get the edid
Quoted 12 lines · Alex Deucher
We keep a cached version of the edid in
radeon_connectorwhich we use for determining connectedness and when to enable certain features like hdmi audio, etc. When the user uses the firmware interface to override the driver with some other edid the driver's copy is never updated. The fetch function will check if there is a user supplied edid and update the driver's copy if there is.bug:
https://bugs.freedesktop.org/show_bug.cgi?id=80691Signed-off-by Alex Deucher <[email protected]>
[snip]
Quoted 4 lines
drivers/gpu/drm/radeon/radeon_connectors.c +4
-0+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;
drivers/gpu/drm/radeon/radeon_connectors.c static struct drm_encoder *radeon_find_encoder(struct drm_connector *connector, · line 284
Quoted 10 lines
drivers/gpu/drm/radeon/radeon_connectors.c +10
-0+ +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; +}
We have similar issues on intel now that we use the debugfs interface to force certain edids (for validating e.g. 4k or 3d) - our code doesn't see the forced edid. Should we have a helper somewhere or just change drm_get_edid to dtrt here?
Adding Thomas who's working on this.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 2/2] drm/radeon: use a fetch function to get the edid
Quoted 36 lines · Daniel Vetter
Quoted 12 lines · Alex Deucher
We keep a cached version of the edid in
radeon_connectorwhich we use for determining connectedness and when to enable certain features like hdmi audio, etc. When the user uses the firmware interface to override the driver with some other edid the driver's copy is never updated. The fetch function will check if there is a user supplied edid and update the driver's copy if there is.bug:
https://bugs.freedesktop.org/show_bug.cgi?id=80691Signed-off-by Alex Deucher <[email protected]>[snip]
Quoted 4 lines
(quoted diff) +4
-0+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;Review
Quoted 10 lines
(quoted diff) +10
-0+ + 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; +}We have similar issues on intel now that we use the debugfs interface to force certain edids (for validating e.g. 4k or 3d) - our code doesn't see the forced edid. Should we have a helper somewhere or just change
drm_get_edidto dtrt here?
Quoted 1 line
Adding Thomas who's working on this.
I think the best solution would be to make drm_load_edid_firmware() just return the raw user supplied edid, then let the drivers handle it internally. That way the drivers could decide how they want to handle it in their detect() or get_modes() callbacks. The problem is that if drm_load_edid_firmware() succeeds, the driver's get_modes() callback never gets called. A less invasive alternative would be to add a a get_modes_firmware() callback, e.g.,
(quoted diff) +0 -0
b/drivers/gpu/drm/drm_probe_helper.c
index d22676b..ceb246f 100644
drivers/gpu/drm/drm_probe_helper.c +0 -0
@@ -127,7 +127,10 @@ static int
drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect
}
#ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE
- count = drm_load_edid_firmware(connector);
+ if (connector_funcs->get_modes_firmware)
+ count = (*connector_funcs->get_modes_firmware)(connector);
+ else
+ count = drm_load_edid_firmware(connector);
if (count == 0)
#endif
count = (*connector_funcs->get_modes)(connector);and the driver implementation could mostly just wrap drm_load_edid_firmware, e.g.,
+static int radeon_get_modes_firmware(struct drm_connector *connector) +{
+ struct radeon_connector *radeon_connector =to_radeon_connector(connector);
+ struct drm_property_blob *edid_blob;
+ int ret;
+
+ ret = drm_load_edid_firmware(connector);
+ edid_blob = connector->edid_blob_ptr;
+ /* update the driver's copy of the */
+ if (edid_blob) {+ struct edid *edid = kmemdup(edid_blob->data,edid_blob->length, GFP_KERNEL);
+ if (edid)
+ radeon_connector->edid = edid;
+ }
+
+ return ret;
+}
The problem is that wouldn't give the driver access to the user provided edid at detect() time.
Alex
Re: [PATCH 2/2] drm/radeon: use a fetch function to get the edid
Quoted 89 lines · Alex Deucher
Quoted 36 lines · Daniel Vetter
Quoted 12 lines · Alex Deucher
We keep a cached version of the edid in
radeon_connectorwhich we use for determining connectedness and when to enable certain features like hdmi audio, etc. When the user uses the firmware interface to override the driver with some other edid the driver's copy is never updated. The fetch function will check if there is a user supplied edid and update the driver's copy if there is.bug:
https://bugs.freedesktop.org/show_bug.cgi?id=80691Signed-off-by Alex Deucher <[email protected]>[snip]
Quoted 4 lines
(quoted diff) +4
-0+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;Review
Quoted 10 lines
(quoted diff) +10
-0+ + 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; +}We have similar issues on intel now that we use the debugfs interface to force certain edids (for validating e.g. 4k or 3d) - our code doesn't see the forced edid. Should we have a helper somewhere or just change
drm_get_edidto dtrt here?Quoted 1 line
Adding Thomas who's working on this.
I think the best solution would be to make
drm_load_edid_firmware()just return the raw user supplied edid, then let the drivers handle it internally. That way the drivers could decide how they want to handle it in theirdetect()orget_modes()callbacks. The problem is that ifdrm_load_edid_firmware()succeeds, the driver'sget_modes()callback never gets called. A less invasive alternative would be to add a aget_modes_firmware()callback, e.g.,drivers/gpu/drm/drm_probe_helper.c +0
-0@@ -127,7 +127,10 @@ static intdrm_helper_probe_single_connector_modes_merge_bits(struct
drm_connect}#ifdef
CONFIG_DRM_LOAD_EDID_FIRMWAREdrivers/gpu/drm/drm_probe_helper.c +4
-1- count =drm_load_edid_firmware (connector); +if (connector_funcs->get_modes_firmware) + count = (*connector_funcs->get_modes_firmware)(connector); +else + count =drm_load_edid_firmware (connector); if (count == 0)#endif count = (*connector_funcs->get_modes)(connector);and the driver implementation could mostly just wrap
drm_load_edid_firmware, e.g.,drivers/gpu/drm/drm_probe_helper.c +3
-0+static int radeon_get_modes_firmware (struct drm_connector *connector) +{ + struct radeon_connector *radeon_connector =
to_radeon_connector(connector);drivers/gpu/drm/drm_probe_helper.c +8
-0+struct drm_property_blob *edid_blob; +int ret; + + ret =drm_load_edid_firmware (connector); + edid_blob = connector->edid_blob_ptr; +/* update the driver's copy of the */ +if (edid_blob) { + struct edid *edid = kmemdup(edid_blob->data,
edid_blob->length,GFP_KERNEL);drivers/gpu/drm/drm_probe_helper.c +6
-0+if (edid) + radeon_connector->edid = edid; + } + +return ret; +}
Quoted 2 lines
The problem is that wouldn't give the driver access to the user provided edid at
detect()time.
Yeah, we also do a bunch of things in ->detect, so ->detect not getting called for forced edids is a bit annoying. The other thing is that edid overriding through debugfs at runtime is done differently again, and for those the driver's ->detect actually gets called. Well, if the connector state doesn't get forced.
One idea I've had which is a bit of work is to move all these detection stuff outside of ->detect and into encoder->mode_fixup functions (compute_config in i915). If we then add a function to grab the cached/firmware/overridden edid and use it there it should all work. And at least on i915 you need to do a full modeset to e.g. update the audio status anyway.
->detect would then really only be for probing and generating the mode list while figuring out the actual hw config. And updating driver private stuff in foo_connector would be done only in ->mode_fixup.
I don't see a good way to make things work as-is, at least if we want to run ->detect always (since a lot of driver have important code in there) and make it work with the firmware/debugfs edid forcing and the connector status forcing (through cmdline or again debugfs). -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 2/2] drm/radeon: use a fetch function to get the edid
Quoted 99 lines · Daniel Vetter
Quoted 89 lines · Alex Deucher
Quoted 36 lines · Daniel Vetter
Quoted 12 lines · Alex Deucher
We keep a cached version of the edid in
radeon_connectorwhich we use for determining connectedness and when to enable certain features like hdmi audio, etc. When the user uses the firmware interface to override the driver with some other edid the driver's copy is never updated. The fetch function will check if there is a user supplied edid and update the driver's copy if there is.bug:
https://bugs.freedesktop.org/show_bug.cgi?id=80691Signed-off-by Alex Deucher <[email protected]>[snip]
Quoted 4 lines
(quoted diff) +4
-0+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;Review
Quoted 10 lines
(quoted diff) +10
-0+ + 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; +}We have similar issues on intel now that we use the debugfs interface to force certain edids (for validating e.g. 4k or 3d) - our code doesn't see the forced edid. Should we have a helper somewhere or just change
drm_get_edidto dtrt here?Quoted 1 line
Adding Thomas who's working on this.
I think the best solution would be to make
drm_load_edid_firmware()just return the raw user supplied edid, then let the drivers handle it internally. That way the drivers could decide how they want to handle it in theirdetect()orget_modes()callbacks. The problem is that ifdrm_load_edid_firmware()succeeds, the driver'sget_modes()callback never gets called. A less invasive alternative would be to add a aget_modes_firmware()callback, e.g.,drivers/gpu/drm/drm_probe_helper.c +0
-0@@ -127,7 +127,10 @@ static intdrm_helper_probe_single_connector_modes_merge_bits(struct
drm_connect}#ifdef
CONFIG_DRM_LOAD_EDID_FIRMWAREdrivers/gpu/drm/drm_probe_helper.c +4
-1- count =drm_load_edid_firmware (connector); +if (connector_funcs->get_modes_firmware) + count = (*connector_funcs->get_modes_firmware)(connector); +else + count =drm_load_edid_firmware (connector); if (count == 0)#endif count = (*connector_funcs->get_modes)(connector);and the driver implementation could mostly just wrap
drm_load_edid_firmware, e.g.,drivers/gpu/drm/drm_probe_helper.c +3
-0+static int radeon_get_modes_firmware (struct drm_connector *connector) +{ + struct radeon_connector *radeon_connector =
to_radeon_connector(connector);drivers/gpu/drm/drm_probe_helper.c +8
-0+struct drm_property_blob *edid_blob; +int ret; + + ret =drm_load_edid_firmware (connector); + edid_blob = connector->edid_blob_ptr; +/* update the driver's copy of the */ +if (edid_blob) { + struct edid *edid = kmemdup(edid_blob->data,
edid_blob->length,GFP_KERNEL);drivers/gpu/drm/drm_probe_helper.c +6
-0+if (edid) + radeon_connector->edid = edid; + } + +return ret; +}Quoted 2 lines
The problem is that wouldn't give the driver access to the user provided edid at
detect()time.Yeah, we also do a bunch of things in ->detect, so ->detect not getting called for forced edids is a bit annoying. The other thing is that edid overriding through debugfs at runtime is done differently again, and for those the driver's ->detect actually gets called. Well, if the connector state doesn't get forced.
Quoted 7 lines
One idea I've had which is a bit of work is to move all these detection stuff outside of ->detect and into
encoder->mode_fixupfunctions (compute_configin i915). If we then add a function to grab the cached/firmware/overridden edid and use it there it should all work. And at least on i915 you need to do a full modeset to e.g. update the audio status anyway.
Same here. My initial version of the patch just moved the edid assignment into the mode_valid() callback since that was the next time the common code called into the driver, but mode_fixup would work as well.
Alex
Quoted 13 lines
->detect would then really only be for probing and generating the mode list while figuring out the actual hw config. And updating driver private stuff in
foo_connectorwould be done only in ->mode_fixup.I don't see a good way to make things work as-is, at least if we want to run ->detect always (since a lot of driver have important code in there) and make it work with the
firmware/debugfsedid forcing and the connector status forcing (through cmdline or again debugfs). -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 2/2] drm/radeon: use a fetch function to get the edid
Quoted 108 lines · Alex Deucher
Quoted 99 lines · Daniel Vetter
Quoted 89 lines · Alex Deucher
Quoted 36 lines · Daniel Vetter
Quoted 12 lines · Alex Deucher
We keep a cached version of the edid in
radeon_connectorwhich we use for determining connectedness and when to enable certain features like hdmi audio, etc. When the user uses the firmware interface to override the driver with some other edid the driver's copy is never updated. The fetch function will check if there is a user supplied edid and update the driver's copy if there is.bug:
https://bugs.freedesktop.org/show_bug.cgi?id=80691Signed-off-by Alex Deucher <[email protected]>[snip]
Quoted 4 lines
(quoted diff) +4
-0+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;Review
Quoted 10 lines
(quoted diff) +10
-0+ + 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; +}We have similar issues on intel now that we use the debugfs interface to force certain edids (for validating e.g. 4k or 3d) - our code doesn't see the forced edid. Should we have a helper somewhere or just change
drm_get_edidto dtrt here?Quoted 1 line
Adding Thomas who's working on this.
I think the best solution would be to make
drm_load_edid_firmware()just return the raw user supplied edid, then let the drivers handle it internally. That way the drivers could decide how they want to handle it in theirdetect()orget_modes()callbacks. The problem is that ifdrm_load_edid_firmware()succeeds, the driver'sget_modes()callback never gets called. A less invasive alternative would be to add a aget_modes_firmware()callback, e.g.,drivers/gpu/drm/drm_probe_helper.c +0
-0@@ -127,7 +127,10 @@ static intdrm_helper_probe_single_connector_modes_merge_bits(struct
drm_connect}#ifdef
CONFIG_DRM_LOAD_EDID_FIRMWAREdrivers/gpu/drm/drm_probe_helper.c +4
-1- count =drm_load_edid_firmware (connector); +if (connector_funcs->get_modes_firmware) + count = (*connector_funcs->get_modes_firmware)(connector); +else + count =drm_load_edid_firmware (connector); if (count == 0)#endif count = (*connector_funcs->get_modes)(connector);and the driver implementation could mostly just wrap
drm_load_edid_firmware, e.g.,drivers/gpu/drm/drm_probe_helper.c +3
-0+static int radeon_get_modes_firmware (struct drm_connector *connector) +{ + struct radeon_connector *radeon_connector =
to_radeon_connector(connector);drivers/gpu/drm/drm_probe_helper.c +8
-0+struct drm_property_blob *edid_blob; +int ret; + + ret =drm_load_edid_firmware (connector); + edid_blob = connector->edid_blob_ptr; +/* update the driver's copy of the */ +if (edid_blob) { + struct edid *edid = kmemdup(edid_blob->data,
edid_blob->length,GFP_KERNEL);drivers/gpu/drm/drm_probe_helper.c +6
-0+if (edid) + radeon_connector->edid = edid; + } + +return ret; +}Quoted 2 lines
The problem is that wouldn't give the driver access to the user provided edid at
detect()time.Yeah, we also do a bunch of things in ->detect, so ->detect not getting called for forced edids is a bit annoying. The other thing is that edid overriding through debugfs at runtime is done differently again, and for those the driver's ->detect actually gets called. Well, if the connector state doesn't get forced.
Quoted 7 lines
One idea I've had which is a bit of work is to move all these detection stuff outside of ->detect and into
encoder->mode_fixupfunctions (compute_configin i915). If we then add a function to grab the cached/firmware/overridden edid and use it there it should all work. And at least on i915 you need to do a full modeset to e.g. update the audio status anyway.
Quoted 4 lines
Same here. My initial version of the patch just moved the edid assignment into the
mode_valid()callback since that was the next time the common code called into the driver, butmode_fixupwould work as well.
So you'll create a new drm_connector_get_cooked_edid or similar which drivers could use for this purpose? Obviously we can't fix all the drivers to dtrt with this approach, but documenting the best practices and adding the helper to drm_probe_helper would be great.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch