Skip to contentSkip to conversation

gma500: Skip bogus LVDS VBT mode and check for LVDS before adding backlight

PATCH In review Patrik Jakobsson 3 participants 4 messages May 11, 2011 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gma500: Skip bogus LVDS VBT mode and check for LVDS before adding backlight

On the Fit-PC2 the VBT reports an invalid fixed panel mode for LVDS, this gets in the way for SDVO. This patch makes VBT parsing skip the invalid mode. When there is no LVDS output the backlight support crashes so the patch also checks for this before enabling it.

---

drivers/staging/gma500/psb_drv.c +14 -1
index 46ab028..b701304 100644
@@ -542,6 +542,8 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 	unsigned long irqflags;
 	int ret = -ENOMEM;
 	uint32_t tt_pages;
+	struct drm_connector *connector;
+	struct psb_intel_output *psb_intel_output;
 
 	dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
 	if (dev_priv == NULL)
@@ -663,7 +665,18 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 		drm_kms_helper_poll_init(dev);
 	}
 
-	ret = psb_backlight_init(dev);
+	/* Only add backlight support if we have LVDS output */
+	list_for_each_entry(connector, &dev->mode_config.connector_list,
+			    head) {
+		psb_intel_output = to_psb_intel_output(connector);
+
+		switch (psb_intel_output->type) {
+		case INTEL_OUTPUT_LVDS:
+			ret = psb_backlight_init(dev);
+			break;
+		}
+	}
+
 	if (ret)
 		return ret;
 #if 0
drivers/staging/gma500/psb_intel_bios.c +9 -4
index 48ac8ba..417965d 100644
@@ -154,10 +154,15 @@ static void parse_lfp_panel_data(struct drm_psb_private *dev_priv,
 
 	fill_detail_timing_data(panel_fixed_mode, dvo_timing);
 
-	dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode;
-
-	DRM_DEBUG("Found panel mode in BIOS VBT tables:\n");
-	drm_mode_debug_printmodeline(panel_fixed_mode);
+	if (panel_fixed_mode->htotal > 0 && panel_fixed_mode->vtotal > 0) {
+		dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode;
+		DRM_DEBUG("Found panel mode in BIOS VBT tables:\n");
+		drm_mode_debug_printmodeline(panel_fixed_mode);
+	} else {
+		DRM_DEBUG("Ignoring bogus LVDS VBT mode.\n");
+		dev_priv->lvds_vbt = 0;
+		kfree(panel_fixed_mode);
+	}
 
 	return;
 }
#1 lore raw
Quoted 4 lines · On Wed, 11 May 2011 19:20:53 +0200 Patrik Jakobsson…

On the Fit-PC2 the VBT reports an invalid fixed panel mode for LVDS, this gets in the way for SDVO. This patch makes VBT parsing skip the invalid mode. When there is no LVDS output the backlight support crashes so the patch also checks for this before enabling it.

Looks good for now. The backlight is a bit more complicated I think (users can turn on the LVDS at runtime in theory) but we can handle that later so long as we tag it with a /* FIXME: Handle turning on LVDS at runtime */

Alan

#2 lore raw
Quoted 8 lines · Alan Cox
Quoted 4 lines · On Wed, 11 May 2011 19:20:53 +0200 Patrik Jakobsson…

On the Fit-PC2 the VBT reports an invalid fixed panel mode for LVDS, this gets in the way for SDVO. This patch makes VBT parsing skip the invalid mode. When there is no LVDS output the backlight support crashes so the patch also checks for this before enabling it.

Quoted 6 lines

Looks good for now. The backlight is a bit more complicated I think (users can turn on the LVDS at runtime in theory) but we can handle that later so long as we tag it with a /* FIXME: Handle turning on LVDS at runtime */

Alan

Backlight is only disabled in case no LVDS modes can be found. And in that case, no LVDS connector gets added. Am I understanding you correctly if "in theory" means LVDS can be hotplugged? In that case we have to call psb_intel_lvds_init when hotplug occurs so the output gets added. If so, we should put psb_backlight_init() there.

Please try the following patch on a system with LVDS hooked-up to something.

-Patrik

---

drivers/staging/gma500/psb_drv.c +0 -3
index 46ab028..ed7be24 100644
@@ -663,9 +663,6 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 		drm_kms_helper_poll_init(dev);
 	}
 
-	ret = psb_backlight_init(dev);
-	if (ret)
-		return ret;
 #if 0
 	/*enable runtime pm at last*/
 	pm_runtime_enable(&dev->pdev->dev);
drivers/staging/gma500/psb_intel_bios.c +9 -4
index 48ac8ba..417965d 100644
@@ -154,10 +154,15 @@ static void parse_lfp_panel_data(struct drm_psb_private *dev_priv,
 
 	fill_detail_timing_data(panel_fixed_mode, dvo_timing);
 
-	dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode;
-
-	DRM_DEBUG("Found panel mode in BIOS VBT tables:\n");
-	drm_mode_debug_printmodeline(panel_fixed_mode);
+	if (panel_fixed_mode->htotal > 0 && panel_fixed_mode->vtotal > 0) {
+		dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode;
+		DRM_DEBUG("Found panel mode in BIOS VBT tables:\n");
+		drm_mode_debug_printmodeline(panel_fixed_mode);
+	} else {
+		DRM_DEBUG("Ignoring bogus LVDS VBT mode.\n");
+		dev_priv->lvds_vbt = 0;
+		kfree(panel_fixed_mode);
+	}
 
 	return;
 }
drivers/staging/gma500/psb_intel_lvds.c +3 -0
index b0a225b..081402a 100644
@@ -843,6 +843,9 @@ void psb_intel_lvds_init(struct drm_device *dev,
 		goto failed_find;
 	}
 
+	if (psb_backlight_init(dev))
+		DRM_DEBUG("Backlight initialization failed\n");
+
 	/*
 	 * Blacklist machines with BIOSes that list an LVDS panel without
 	 * actually having one.
#3 lore raw
Quoted 5 lines

Backlight is only disabled in case no LVDS modes can be found. And in that case, no LVDS connector gets added. Am I understanding you correctly if "in theory" means LVDS can be hotplugged? In that case we have to call psb_intel_lvds_init when hotplug occurs so the output gets added. If so, we should put psb_backlight_init() there.

I'm not sure anyone would have a reason to so I don't think anything needs doing but tagging it as a /* FIXME */ to check and sort out eventually.