Skip to content

Commit 53fd40a

Browse files
committed
drm: handle override and firmware EDID at drm_do_get_edid() level
Handle debugfs override edid and firmware edid at the low level to transparently and completely replace the real edid. Previously, we practically only used the modes from the override EDID, and none of the other data, such as audio parameters. This change also prevents actual EDID reads when the EDID is to be overridden, but retains the DDC probe. This is useful if the reason for preferring override EDID are problems with reading the data, or corruption of the data. Move firmware EDID loading from helper to core, as the functionality moves to lower level as well. This will result in a change of module parameter from drm_kms_helper.edid_firmware to drm.edid_firmware, which arguably makes more sense anyway. Some future work remains related to override and firmware EDID validation. Like before, no validation is done for override EDID. The firmware EDID is validated separately in the loader. Some unification and deduplication would be in order, to validate all of them at the drm_do_get_edid() level, like "real" EDIDs. v2: move firmware loading to core v3: rebase, commit message refresh Cc: Abdiel Janulgue <abdiel.janulgue@linux.intel.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Tested-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Acked-by: Dave Airlie <airlied@gmail.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/1e8a710bcac46e5136c1a7b430074893c81f364a.1505203831.git.jani.nikula@intel.com
1 parent c673fe7 commit 53fd40a

5 files changed

Lines changed: 19 additions & 21 deletions

File tree

‎Documentation/admin-guide/kernel-parameters.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@
854854
The filter can be disabled or changed to another
855855
driver later using sysfs.
856856

857-
drm_kms_helper.edid_firmware=[<connector>:]<file>[,[<connector>:]<file>]
857+
drm.edid_firmware=[<connector>:]<file>[,[<connector>:]<file>]
858858
Broken monitors, graphic adapters, KVMs and EDIDless
859859
panels may send no or incorrect EDID data sets.
860860
This parameter allows to specify an EDID data sets

‎drivers/gpu/drm/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ config DRM_FBDEV_OVERALLOC
110110

111111
config DRM_LOAD_EDID_FIRMWARE
112112
bool "Allow to specify an EDID data set instead of probing for it"
113-
depends on DRM_KMS_HELPER
113+
depends on DRM
114114
help
115115
Say Y here, if you want to use EDID data to be loaded from the
116116
/lib/firmware directory or one of the provided built-in

‎drivers/gpu/drm/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ drm-$(CONFIG_DRM_PANEL) += drm_panel.o
2828
drm-$(CONFIG_OF) += drm_of.o
2929
drm-$(CONFIG_AGP) += drm_agpsupport.o
3030
drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
31+
drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
3132

3233
drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
3334
drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
@@ -36,7 +37,6 @@ drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
3637
drm_scdc_helper.o drm_gem_framebuffer_helper.o
3738

3839
drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
39-
drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
4040
drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
4141
drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o
4242
drm_kms_helper-$(CONFIG_DRM_DP_AUX_CHARDEV) += drm_dp_aux_dev.o

‎drivers/gpu/drm/drm_edid.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,10 @@ static void connector_bad_edid(struct drm_connector *connector,
15331533
* level, drivers must make all reasonable efforts to expose it as an I2C
15341534
* adapter and use drm_get_edid() instead of abusing this function.
15351535
*
1536+
* The EDID may be overridden using debugfs override_edid or firmare EDID
1537+
* (drm_load_edid_firmware() and drm.edid_firmware parameter), in this priority
1538+
* order. Having either of them bypasses actual EDID reads.
1539+
*
15361540
* Return: Pointer to valid EDID or NULL if we couldn't find any.
15371541
*/
15381542
struct edid *drm_do_get_edid(struct drm_connector *connector,
@@ -1542,6 +1546,17 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
15421546
{
15431547
int i, j = 0, valid_extensions = 0;
15441548
u8 *edid, *new;
1549+
struct edid *override = NULL;
1550+
1551+
if (connector->override_edid)
1552+
override = drm_edid_duplicate((const struct edid *)
1553+
connector->edid_blob_ptr->data);
1554+
1555+
if (!override)
1556+
override = drm_load_edid_firmware(connector);
1557+
1558+
if (!IS_ERR_OR_NULL(override))
1559+
return override;
15451560

15461561
if ((edid = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL)
15471562
return NULL;

‎drivers/gpu/drm/drm_probe_helper.c‎

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,6 @@ EXPORT_SYMBOL(drm_helper_probe_detect);
353353
* drm_mode_probed_add(). New modes start their life with status as OK.
354354
* Modes are added from a single source using the following priority order.
355355
*
356-
* - debugfs 'override_edid' (used for testing only)
357-
* - firmware EDID (drm_load_edid_firmware())
358356
* - &drm_connector_helper_funcs.get_modes vfunc
359357
* - if the connector status is connector_status_connected, standard
360358
* VESA DMT modes up to 1024x768 are automatically added
@@ -483,22 +481,7 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
483481
goto prune;
484482
}
485483

486-
if (connector->override_edid) {
487-
struct edid *edid = (struct edid *) connector->edid_blob_ptr->data;
488-
489-
count = drm_add_edid_modes(connector, edid);
490-
drm_edid_to_eld(connector, edid);
491-
} else {
492-
struct edid *edid = drm_load_edid_firmware(connector);
493-
if (!IS_ERR_OR_NULL(edid)) {
494-
drm_mode_connector_update_edid_property(connector, edid);
495-
count = drm_add_edid_modes(connector, edid);
496-
drm_edid_to_eld(connector, edid);
497-
kfree(edid);
498-
}
499-
if (count == 0)
500-
count = (*connector_funcs->get_modes)(connector);
501-
}
484+
count = (*connector_funcs->get_modes)(connector);
502485

503486
if (count == 0 && connector->status == connector_status_connected)
504487
count = drm_add_modes_noedid(connector, 1024, 768);

0 commit comments

Comments
 (0)