[Intel-gfx] [PATCH] drm/i915: create sdvo back light property
Ma Ling
ling_ma at linux.intel.com
Tue Jun 9 06:59:31 CEST 2009
Create back light property for sdvo lvds output, and set back light level
by sdvo command. Because SDVO encoder will advertise multiple functions,
we create the property after SDVO detection finish, instead of at
initialization time.
Signed-off-by: Ma Ling <ling.ma at intel.com>
---
The patch is based on patch-
[PATCH V3] drm/i915: Construct all possible sdvo outputs for one sdvo port
drivers/gpu/drm/i915/intel_sdvo.c | 58 +++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 6481dab..ead3993 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -79,6 +79,10 @@ struct intel_sdvo_priv {
uint8_t sdvo_flags;
struct drm_display_mode *sdvo_lvds_fixed_mode;
+ /**
+ * This is set if output is sdvo lvds.
+ */
+ struct drm_property *lvds_backlight_property;
/**
* Returned SDTV resolutions allowed for the current format, if the
@@ -1430,6 +1434,56 @@ void intel_sdvo_set_hotplug(struct drm_connector *connector, int on)
intel_sdvo_read_response(intel_output, &response, 2);
}
+static int
+intel_sdvo_set_property(struct drm_connector *connector,
+ struct drm_property *property, uint64_t val)
+{
+ struct intel_output *intel_output = to_intel_output(connector);
+ struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
+ int ret = 0;
+
+ ret = drm_connector_property_set_value(connector, property, val);
+ if (ret < 0)
+ return ret;
+
+ if (sdvo_priv->is_lvds &&
+ property == sdvo_priv->lvds_backlight_property)
+ intel_sdvo_write_cmd(intel_output,
+ SDVO_CMD_SET_BACKLIGHT_LEVEL, &val, 1);
+
+ return ret;
+
+}
+
+/**
+ * Becuase SDVO encoder will advertise multiple functions,
+ * until detection complete, we can ensure the real output.
+ * So we try to build up sdvo lvds property here.
+ */
+static void intel_sdvo_lvds_property_create(struct drm_device *dev,
+ struct intel_output *intel_output)
+{
+ struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
+ uint16_t response;
+ uint8_t status;
+ sdvo_priv->lvds_backlight_property =
+ drm_property_create(dev, DRM_MODE_PROP_RANGE,
+ "back light", 2);
+ intel_sdvo_write_cmd(intel_output,
+ SDVO_CMD_GET_MAX_BACKLIGHT_LEVEL, NULL, 0);
+ status = intel_sdvo_read_response(intel_output, &response, 2);
+ sdvo_priv->lvds_backlight_property->values[0] = 0;
+ sdvo_priv->lvds_backlight_property->values[0] = response;
+
+ intel_sdvo_write_cmd(intel_output,
+ SDVO_CMD_GET_BACKLIGHT_LEVEL, NULL, 0);
+
+ status = intel_sdvo_read_response(intel_output, &response, 1);
+ drm_connector_attach_property(&intel_output->base,
+ sdvo_priv->lvds_backlight_property,
+ response & 0xff);
+}
+
static void
intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
{
@@ -1463,6 +1517,9 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect
if (response & sdvo_priv->controlled_output) {
intel_sdvo_hdmi_sink_detect(connector);
+ if (sdvo_priv->is_lvds)
+ intel_sdvo_lvds_property_create(connector->dev,
+ intel_output);
return connector_status_connected;
} else
return connector_status_disconnected;
@@ -1704,6 +1761,7 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = {
.detect = intel_sdvo_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
.destroy = intel_sdvo_destroy,
+ .set_property = intel_sdvo_set_property,
};
static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {
--
1.5.4.4
More information about the Intel-gfx
mailing list