From 9b300caf8455dd0b8c3910330b063ff5777f0a36 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 17 Jan 2011 12:07:47 +0000 Subject: [PATCH] grub_video_get_edid is not usable from grub_vbe_get_preferred_mode, as a video adapter has not necessarily yet been set. Use grub_video_vbe_get_edid and grub_video_edid_checksum directly instead. Remove grub_video_get_edid as it now has no users. Reported by: Marjo Mercado. --- ChangeLog.vbe-autodetect | 4 +--- grub-core/video/i386/pc/vbe.c | 39 ++++++++++++++++++----------------- grub-core/video/video.c | 18 ---------------- include/grub/video.h | 1 - 4 files changed, 21 insertions(+), 41 deletions(-) diff --git a/ChangeLog.vbe-autodetect b/ChangeLog.vbe-autodetect index 46aacef7b..3341e8cc3 100644 --- a/ChangeLog.vbe-autodetect +++ b/ChangeLog.vbe-autodetect @@ -1,9 +1,8 @@ -2011-01-15 Colin Watson +2011-01-17 Colin Watson Preferred resolution detection for VBE. * grub-core/video/video.c (grub_video_edid_checksum): New function. - (grub_video_get_edid): Likewise. (grub_video_edid_preferred_mode): Likewise. Try EDID followed by the Flat Panel extension, in line with the X.org VESA driver. * grub-core/video/i386/pc/vbe.c (grub_vbe_bios_get_flat_panel_info): @@ -21,7 +20,6 @@ * include/grub/video.h (struct grub_vbe_edid_info): New structure. (struct grub_video_adapter): Add get_edid. (grub_video_edid_checksum): Add prototype. - (grub_video_get_edid): Likewise. (grub_video_edid_preferred_mode): Likewise. * include/grub/i386/pc/vbe.h (struct grub_vbe_flat_panel_info): New structure. diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c index c2b35a851..f94b06060 100644 --- a/grub-core/video/i386/pc/vbe.c +++ b/grub-core/video/i386/pc/vbe.c @@ -377,6 +377,24 @@ grub_vbe_probe (struct grub_vbe_info_block *info_block) return GRUB_ERR_NONE; } +static grub_err_t +grub_video_vbe_get_edid (struct grub_video_edid_info *edid_info) +{ + struct grub_video_edid_info *edid_info_lowmem; + + /* Use low memory scratch area as temporary storage for VESA BIOS calls. */ + edid_info_lowmem = + (struct grub_video_edid_info *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR; + grub_memset (edid_info_lowmem, 0, sizeof (*edid_info_lowmem)); + + if (grub_vbe_bios_read_edid (edid_info_lowmem) != GRUB_VBE_STATUS_OK) + return grub_error (GRUB_ERR_BAD_DEVICE, "EDID information not available"); + + grub_memcpy (edid_info, edid_info_lowmem, sizeof (*edid_info)); + + return GRUB_ERR_NONE; +} + static grub_err_t grub_vbe_get_preferred_mode (unsigned int *width, unsigned int *height) { @@ -394,7 +412,8 @@ grub_vbe_get_preferred_mode (unsigned int *width, unsigned int *height) && (grub_vbe_bios_get_ddc_capabilities (&ddc_level) & 0xff) == GRUB_VBE_STATUS_OK) { - if (grub_video_get_edid (&edid_info) == GRUB_ERR_NONE + if (grub_video_vbe_get_edid (&edid_info) == GRUB_ERR_NONE + && grub_video_edid_checksum (&edid_info) == GRUB_ERR_NONE && grub_video_edid_preferred_mode (&edid_info, width, height) == GRUB_ERR_NONE) return GRUB_ERR_NONE; @@ -969,24 +988,6 @@ grub_video_vbe_get_info_and_fini (struct grub_video_mode_info *mode_info, return grub_video_fb_get_info_and_fini (mode_info, framebuf); } -static grub_err_t -grub_video_vbe_get_edid (struct grub_video_edid_info *edid_info) -{ - struct grub_video_edid_info *edid_info_lowmem; - - /* Use low memory scratch area as temporary storage for VESA BIOS calls. */ - edid_info_lowmem = - (struct grub_video_edid_info *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR; - grub_memset (edid_info_lowmem, 0, sizeof (*edid_info_lowmem)); - - if (grub_vbe_bios_read_edid (edid_info_lowmem) != GRUB_VBE_STATUS_OK) - return grub_error (GRUB_ERR_BAD_DEVICE, "EDID information not available"); - - grub_memcpy (edid_info, edid_info_lowmem, sizeof (*edid_info)); - - return GRUB_ERR_NONE; -} - static void grub_video_vbe_print_adapter_specific_info (void) { diff --git a/grub-core/video/video.c b/grub-core/video/video.c index 84e98bb67..01bdd1ff3 100644 --- a/grub-core/video/video.c +++ b/grub-core/video/video.c @@ -393,24 +393,6 @@ grub_video_edid_checksum (struct grub_video_edid_info *edid_info) return grub_errno; } -grub_err_t -grub_video_get_edid (struct grub_video_edid_info *edid_info) -{ - if (! grub_video_adapter_active) - return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated"); - - if (! grub_video_adapter_active->get_edid) - return grub_error (GRUB_ERR_BAD_DEVICE, - "EDID information unavailable for this video mode"); - - if (grub_video_adapter_active->get_edid (edid_info) != GRUB_ERR_NONE) - return grub_errno; - if (grub_video_edid_checksum (edid_info) != GRUB_ERR_NONE) - return grub_errno; - - return GRUB_ERR_NONE; -} - grub_err_t grub_video_edid_preferred_mode (struct grub_video_edid_info *edid_info, unsigned int *width, unsigned int *height) diff --git a/include/grub/video.h b/include/grub/video.h index 2251ed5f4..f42730a7d 100644 --- a/include/grub/video.h +++ b/include/grub/video.h @@ -486,7 +486,6 @@ grub_err_t EXPORT_FUNC (grub_video_set_active_render_target) (struct grub_video_ grub_err_t grub_video_get_active_render_target (struct grub_video_render_target **target); grub_err_t grub_video_edid_checksum (struct grub_video_edid_info *edid_info); -grub_err_t grub_video_get_edid (struct grub_video_edid_info *edid_info); grub_err_t grub_video_edid_preferred_mode (struct grub_video_edid_info *edid_info, unsigned int *width, unsigned int *height);