From dd2a3ac6352aacd324a0c64c67ffbb13389bb075 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Mon, 8 Mar 2010 14:29:12 +0800 Subject: [PATCH 2/2] drm/i915: Obtain the current TV format Signed-off-by: Zhao Yakui --- drivers/gpu/drm/i915/intel_sdvo.c | 36 +++++++++++++++++++++++++++++++++++- 1 files changed, 35 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c index c0121a3..f5accf1 100644 --- a/drivers/gpu/drm/i915/intel_sdvo.c +++ b/drivers/gpu/drm/i915/intel_sdvo.c @@ -1072,7 +1072,30 @@ static void intel_sdvo_set_tv_format(struct intel_output *output) DRM_DEBUG_KMS("%s: Failed to set TV format\n", SDVO_NAME(sdvo_priv)); } +static void intel_sdvo_get_current_tv_format(struct intel_output *intel_output) +{ + struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; + struct intel_sdvo_tv_format format; + uint32_t format_map; + char *temp_tv_format = NULL; + uint8_t status; + intel_sdvo_set_target_output(intel_output, + sdvo_priv->controlled_output); + /* Get the current TV format */ + memset(&format, 0, sizeof(format)); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_TV_FORMAT, NULL, 0); + status = intel_sdvo_read_response(intel_output, + &format, sizeof(format)); + if (status == SDVO_CMD_STATUS_SUCCESS) { + memcpy(&format_map, &format, sizeof(format) > sizeof(format_map) ? + sizeof(format_map) : sizeof(format)); + temp_tv_format = tv_format_names[fls(format_map) - 1]; + printk(KERN_DEBUG "Intel_SDVO Current TV format is %s\n", + temp_tv_format); + } else + printk(KERN_DEBUG "Can't obtain the current TV format \n"); +} static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) @@ -1095,6 +1118,8 @@ static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder, intel_sdvo_get_dtd_from_mode(&output_dtd, mode); intel_sdvo_set_target_output(output, dev_priv->controlled_output); + + intel_sdvo_get_current_tv_format(output); intel_sdvo_set_output_timing(output, &output_dtd); /* Set the input timing to the screen. Assume always input 0. */ @@ -1230,8 +1255,10 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder, /* Set the input timing to the screen. Assume always input 0. */ intel_sdvo_set_target_input(output, true, false); - if (sdvo_priv->is_tv) + if (sdvo_priv->is_tv) { + intel_sdvo_get_current_tv_format(output); intel_sdvo_set_tv_format(output); + } /* We would like to use intel_sdvo_create_preferred_input_timing() to * provide the device with a timing it can support, if it supports that @@ -1822,6 +1849,7 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector) uint8_t status; + intel_sdvo_get_current_tv_format(output); /* Read the list of supported input resolutions for the selected TV * format. */ @@ -2007,6 +2035,7 @@ intel_sdvo_set_property(struct drm_connector *connector, sdvo_priv->tv_format_name = sdvo_priv->tv_format_supported[val]; changed = true; + intel_sdvo_set_tv_format(intel_output); } if (sdvo_priv->is_tv || sdvo_priv->is_lvds) { @@ -2433,10 +2462,15 @@ static void intel_sdvo_tv_create_property(struct drm_connector *connector) sdvo_priv->tv_format_property, i, i, sdvo_priv->tv_format_supported[i]); + /* Get the current TV format */ sdvo_priv->tv_format_name = sdvo_priv->tv_format_supported[0]; drm_connector_attach_property( connector, sdvo_priv->tv_format_property, 0); + DRM_DEBUG_KMS("the TV format initialized by driver is %s\n", + sdvo_priv->tv_format_name); + intel_sdvo_get_current_tv_format(intel_output); + } static void intel_sdvo_create_enhance_property(struct drm_connector *connector) -- 1.5.4.5