[PATCH 1/3] drm/edid: reverse display info preserve/clear logic, defaulting to clear

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of explicitly clearing individual struct drm_display_info
members manually, default to clearing everything and preserving the
members that currently do need to be preserved manually. The goal is to
avoid adding new members while forgetting to clear them.

Use a little bit of macro magic to avoid duplicating the types. There
should be no functional changes.

The long term goal is to move the members that are modified by drivers
and need to be preserved out of display info.

Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
---
 drivers/gpu/drm/drm_edid.c | 50 ++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 3d0a4da661bc..6dc4591da0bc 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -6401,36 +6401,32 @@ static void drm_update_mso(struct drm_connector *connector,
 static void drm_reset_display_info(struct drm_connector *connector)
 {
 	struct drm_display_info *info = &connector->display_info;
-
-	info->width_mm = 0;
-	info->height_mm = 0;
-
-	info->bpc = 0;
-	info->color_formats = 0;
-	info->cea_rev = 0;
-	info->max_tmds_clock = 0;
-	info->dvi_dual = false;
-	info->is_hdmi = false;
-	info->has_hdmi_infoframe = false;
-	info->rgb_quant_range_selectable = false;
-	memset(&info->hdmi, 0, sizeof(info->hdmi));
-
-	info->edid_hdmi_rgb444_dc_modes = 0;
-	info->edid_hdmi_ycbcr444_dc_modes = 0;
-
-	info->non_desktop = 0;
-	memset(&info->monitor_range, 0, sizeof(info->monitor_range));
-	memset(&info->luminance_range, 0, sizeof(info->luminance_range));
-
-	info->mso_stream_count = 0;
-	info->mso_pixel_overlap = 0;
-	info->max_dsc_bpp = 0;
+#define COPY_MEMBER(__member) __auto_type __member = info->__member
+	COPY_MEMBER(subpixel_order);
+	COPY_MEMBER(panel_orientation);
+	COPY_MEMBER(bus_formats);
+	COPY_MEMBER(num_bus_formats);
+	COPY_MEMBER(bus_flags);
+#undef COPY_MEMBER
 
 	kfree(info->vics);
-	info->vics = NULL;
-	info->vics_len = 0;
 
-	info->quirks = 0;
+	memset(info, 0, sizeof(*info));
+
+	/*
+	 * Preserve certain members across display info resets. These are
+	 * modified by drivers, and do not originate from the EDID. Please try
+	 * to avoid adding more.
+	 *
+	 * FIXME: Move all of these to a separate drm_connector sub-struct, and
+	 * make struct drm_display_info purely about info originating from the
+	 * EDID.
+	 */
+	info->subpixel_order = subpixel_order;
+	info->panel_orientation = panel_orientation;
+	info->bus_formats = bus_formats; /* Note: pointer copy! */
+	info->num_bus_formats = num_bus_formats;
+	info->bus_flags = bus_flags;
 }
 
 static void update_display_info(struct drm_connector *connector,
-- 
2.34.1




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux