diff options
-rw-r--r-- | linux-core/intel_sdvo.c | 99 |
1 files changed, 62 insertions, 37 deletions
diff --git a/linux-core/intel_sdvo.c b/linux-core/intel_sdvo.c index 5dbfb8eb..c9bc692e 100644 --- a/linux-core/intel_sdvo.c +++ b/linux-core/intel_sdvo.c @@ -253,30 +253,38 @@ static u8 intel_sdvo_read_response(struct drm_output *output, void *response, struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; int i; u8 status; + u8 retry = 50; - /* Read the command response */ - for (i = 0; i < response_len; i++) { - intel_sdvo_read_byte(output, SDVO_I2C_RETURN_0 + i, + while (retry--) { + /* Read the command response */ + for (i = 0; i < response_len; i++) { + intel_sdvo_read_byte(output, SDVO_I2C_RETURN_0 + i, &((u8 *)response)[i]); - } + } - /* read the return status */ - intel_sdvo_read_byte(output, SDVO_I2C_CMD_STATUS, &status); + /* read the return status */ + intel_sdvo_read_byte(output, SDVO_I2C_CMD_STATUS, &status); + + if (1) { + printk("%s: R: ", SDVO_NAME(sdvo_priv)); + for (i = 0; i < response_len; i++) + printk("%02X ", ((u8 *)response)[i]); + for (; i < 8; i++) + printk(" "); + if (status <= SDVO_CMD_STATUS_SCALING_NOT_SUPP) + printk("(%s)", cmd_status_names[status]); + else + printk("(??? %d)", status); + printk("\n"); + } - if (1) { - printk("%s: R: ", SDVO_NAME(sdvo_priv)); - for (i = 0; i < response_len; i++) - printk("%02X ", ((u8 *)response)[i]); - for (; i < 8; i++) - printk(" "); - if (status <= SDVO_CMD_STATUS_SCALING_NOT_SUPP) - printk("(%s)", cmd_status_names[status]); - else - printk("(??? %d)", status); - printk("\n"); - } - return status; + if (status != SDVO_CMD_STATUS_PENDING) + return status; + + mdelay(50); + } + return SDVO_CMD_STATUS_SUCCESS; } int intel_sdvo_get_pixel_multiplier(struct drm_display_mode *mode) @@ -289,9 +297,14 @@ int intel_sdvo_get_pixel_multiplier(struct drm_display_mode *mode) return 4; } -static void intel_sdvo_set_control_bus_switch(struct drm_output *output, u8 target) +static bool intel_sdvo_set_control_bus_switch(struct drm_output *output, u8 target) { + u8 status; + intel_sdvo_write_cmd(output, SDVO_CMD_SET_CONTROL_BUS_SWITCH, &target, 1); + status = intel_sdvo_read_response(output, NULL, 0); + + return (status == SDVO_CMD_STATUS_SUCCESS); } static bool intel_sdvo_set_target_input(struct drm_output *output, bool target_0, bool target_1) @@ -869,21 +882,9 @@ static enum drm_output_status intel_sdvo_detect(struct drm_output *output) { u8 response[2]; u8 status; - u8 retry = 50; intel_sdvo_write_cmd(output, SDVO_CMD_GET_ATTACHED_DISPLAYS, NULL, 0); - - while (retry--) { - status = intel_sdvo_read_response(output, &response, 2); - - if (status == SDVO_CMD_STATUS_SUCCESS) - break; - - if (status != SDVO_CMD_STATUS_PENDING) - return output_status_unknown; - - mdelay(50); - } + status = intel_sdvo_read_response(output, &response, 2); DRM_DEBUG("SDVO response %d %d\n", response[0], response[1]); if ((response[0] != 0) || (response[1] != 0)) @@ -1012,7 +1013,28 @@ void intel_sdvo_init(drm_device_t *dev, int output_device) memset(&sdvo_priv->active_outputs, 0, sizeof(sdvo_priv->active_outputs)); - if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0) + /* TODO, CVBS, SVID, YPRPB & SCART outputs. + * drm_initial_config probably wants tweaking too to support the + * above. But has fixed VGA, TMDS and LVDS checking code. That should + * be dealt with. + */ + if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB0) + { + sdvo_priv->active_outputs = SDVO_OUTPUT_RGB0; + output->subpixel_order = SubPixelHorizontalRGB; + /* drm_initial_config wants this name, but should be RGB */ + /* Use this for now.... */ + name_prefix="VGA"; + } + else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1) + { + sdvo_priv->active_outputs = SDVO_OUTPUT_RGB1; + output->subpixel_order = SubPixelHorizontalRGB; + /* drm_initial_config wants this name, but should be RGB */ + /* Use this for now.... */ + name_prefix="VGA"; + } + else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0) { sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS0; output->subpixel_order = SubPixelHorizontalRGB; @@ -1029,7 +1051,7 @@ void intel_sdvo_init(drm_device_t *dev, int output_device) unsigned char bytes[2]; memcpy (bytes, &sdvo_priv->caps.output_flags, 2); - DRM_DEBUG("%s: No active TMDS outputs (0x%02x%02x)\n", + DRM_DEBUG("%s: No active RGB or TMDS outputs (0x%02x%02x)\n", SDVO_NAME(sdvo_priv), bytes[0], bytes[1]); } @@ -1061,8 +1083,11 @@ void intel_sdvo_init(drm_device_t *dev, int output_device) sdvo_priv->pixel_clock_max / 1000, (sdvo_priv->caps.sdvo_inputs_mask & 0x1) ? 'Y' : 'N', (sdvo_priv->caps.sdvo_inputs_mask & 0x2) ? 'Y' : 'N', - sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0 ? 'Y' : 'N', - sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS1 ? 'Y' : 'N'); + /* check currently supported outputs */ + sdvo_priv->caps.output_flags & + (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_RGB0) ? 'Y' : 'N', + sdvo_priv->caps.output_flags & + (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N'); intel_output->ddc_bus = i2cbus; } |