/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
/* The list of video adapters registered to system. */
/* Active video adapter. */
/* Restore back to initial mode (where applicable). */
grub_video_restore (void)
{
{
if (grub_errno != GRUB_ERR_NONE)
return grub_errno;
}
return GRUB_ERR_NONE;
}
/* Get information about active video mode. */
{
if (! grub_video_adapter_active)
/* If mode_info is NULL just report that video adapter is active. */
if (! mode_info)
{
return grub_errno;
}
}
grub_video_get_driver_id (void)
{
if (! grub_video_adapter_active)
return GRUB_VIDEO_DRIVER_NONE;
return grub_video_adapter_active->id;
}
/* Get information about active video mode. */
void **framebuffer)
{
if (! grub_video_adapter_active)
if (err)
return err;
return GRUB_ERR_NONE;
}
/* Determine optimized blitting formation for specified video mode info. */
{
/* Check if we have any known 32 bit modes. */
{
&& (mode_info->blue_field_pos == 0))
{
return GRUB_VIDEO_BLIT_FORMAT_BGRA_8888;
}
&& (mode_info->red_field_pos == 0)
{
return GRUB_VIDEO_BLIT_FORMAT_RGBA_8888;
}
}
/* Check if we have any known 24 bit modes. */
{
&& (mode_info->blue_field_pos == 0))
{
return GRUB_VIDEO_BLIT_FORMAT_BGR_888;
}
&& (mode_info->red_field_pos == 0)
{
return GRUB_VIDEO_BLIT_FORMAT_RGB_888;
}
}
/* Check if we have any known 16 bit modes. */
{
&& (mode_info->blue_field_pos == 0))
{
return GRUB_VIDEO_BLIT_FORMAT_BGR_565;
}
&& (mode_info->red_field_pos == 0)
{
return GRUB_VIDEO_BLIT_FORMAT_RGB_565;
}
}
/* Backup route. Unknown format. */
/* If there are more than 8 bits per color, assume RGB(A) mode. */
{
if (mode_info->reserved_mask_size > 0)
{
return GRUB_VIDEO_BLIT_FORMAT_RGBA;
}
else
{
return GRUB_VIDEO_BLIT_FORMAT_RGB;
}
}
/* Assume as indexcolor mode. */
}
/* Set new indexed color palette entries. */
struct grub_video_palette_data *palette_data)
{
if (! grub_video_adapter_active)
}
/* Get indexed color palette entries. */
struct grub_video_palette_data *palette_data)
{
if (! grub_video_adapter_active)
}
/* Set viewport dimensions. */
grub_video_set_viewport (unsigned int x, unsigned int y,
{
if (! grub_video_adapter_active)
}
/* Get viewport dimensions. */
grub_video_get_viewport (unsigned int *x, unsigned int *y,
{
if (! grub_video_adapter_active)
}
/* Map color name to adapter specific color. */
{
if (! grub_video_adapter_active)
return 0;
}
/* Map RGB value to adapter specific color. */
{
if (! grub_video_adapter_active)
return 0;
}
/* Map RGBA value to adapter specific color. */
{
if (! grub_video_adapter_active)
return 0;
}
/* Unmap video color back to RGBA components. */
{
if (! grub_video_adapter_active)
red,
blue,
alpha);
}
/* Fill rectangle using specified color. */
{
if (! grub_video_adapter_active)
}
/* Blit bitmap to screen. */
{
if (! grub_video_adapter_active)
}
/* Blit render target to active render target. */
{
if (! grub_video_adapter_active)
}
/* Scroll viewport and fill new areas with specified color. */
{
if (! grub_video_adapter_active)
}
/* Swap buffers (swap active render target). */
grub_video_swap_buffers (void)
{
if (! grub_video_adapter_active)
return grub_video_adapter_active->swap_buffers ();
}
/* Create new render target. */
unsigned int mode_type)
{
if (! grub_video_adapter_active)
}
/* Delete render target. */
{
if (! grub_video_adapter_active)
}
/* Set active render target. */
{
if (! grub_video_adapter_active)
}
/* Get active render target. */
{
if (! grub_video_adapter_active)
}
{
int i;
char checksum = 0;
/* Check EDID checksum. */
for (i = 0; i < 128; ++i)
checksum += edid_bytes[i];
if (checksum != 0)
return grub_error (GRUB_ERR_BAD_DEVICE,
"invalid EDID checksum %d", checksum);
return grub_errno;
}
{
/* Bit 1 in the Feature Support field indicates that the first
Detailed Timing Description is the preferred timing mode. */
&& (edid_info->feature_support
{
| (((unsigned int)
<< 4);
| (((unsigned int)
<< 4);
return GRUB_ERR_NONE;
}
}
/* Parse <width>x<height>[x<depth>]*/
static grub_err_t
{
const char *value;
{
return GRUB_ERR_NONE;
}
/* Find width value. */
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Invalid mode: %s\n",
param++;
if (grub_errno != GRUB_ERR_NONE)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Invalid mode: %s\n",
/* Find height value. */
{
if (grub_errno != GRUB_ERR_NONE)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Invalid mode: %s\n",
}
else
{
/* We have optional color depth value. */
param++;
if (grub_errno != GRUB_ERR_NONE)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Invalid mode: %s\n",
/* Convert color depth value. */
if (grub_errno != GRUB_ERR_NONE)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"Invalid mode: %s\n",
}
return GRUB_ERR_NONE;
}
unsigned int modemask,
unsigned int modevalue)
{
char *tmp;
char *next_mode;
char *current_mode;
char *modevar;
/* Take copy of env.var. as we don't want to modify that. */
/* Initialize next mode. */
if (! modevar)
return grub_error (GRUB_ERR_OUT_OF_MEMORY,
"couldn't allocate space for local modevar copy");
{
{
if (err)
{
suitable = 0;
}
suitable = 0;
}
else if (((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modemask) != 0)
&& ((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modevalue) == 0))
suitable = 0;
if (suitable)
{
return GRUB_ERR_NONE;
}
if (! *next_mode)
{
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"no suitable mode found");
}
/* Skip separator. */
next_mode++;
}
/* De-activate last set video adapter. */
{
/* Finalize adapter. */
if (grub_errno != GRUB_ERR_NONE)
/* Mark active adapter as not set. */
}
/* Loop until all modes has been tested out. */
{
/* Use last next_mode as current mode. */
/* Save position of next mode and separate modes. */
break;
if (*next_mode)
{
*next_mode = 0;
next_mode++;
}
else
next_mode = 0;
/* Skip whitespace. */
while (grub_isspace (*tmp))
tmp++;
/* Initialize token holders. */
current_mode = tmp;
/* XXX: we assume that we're in pure text mode if
no video mode is initialized. Is it always true? */
{
if (((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modemask) == 0)
|| ((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modevalue) != 0))
{
/* Valid mode found from adapter, and it has been activated.
Specify it as active adapter. */
/* Free memory. */
return GRUB_ERR_NONE;
}
}
if (err)
{
/* Free memory before returning. */
return err;
}
/* Try out video mode. */
/* If user requested specific depth check if this depth is supported. */
&&
!= ((depth << GRUB_VIDEO_MODE_TYPE_DEPTH_POS)
continue;
if (depth != -1)
{
}
/* Try to initialize requested mode. Ignore any errors. */
/* Loop thru all possible video adapter trying to find requested mode. */
for (p = grub_video_adapter_list; p; p = p->next)
{
/* Try to initialize adapter, if it fails, skip to next adapter. */
if (err != GRUB_ERR_NONE)
{
continue;
}
/* Try to initialize video mode. */
if (err != GRUB_ERR_NONE)
{
p->fini ();
continue;
}
if (err != GRUB_ERR_NONE)
{
p->fini ();
continue;
}
/* Check that mode is suitable for upper layer. */
if ((flags & GRUB_VIDEO_MODE_TYPE_PURE_TEXT)
? (((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modemask) != 0)
&& ((GRUB_VIDEO_MODE_TYPE_PURE_TEXT & modevalue) == 0))
{
p->fini ();
continue;
}
/* Valid mode found from adapter, and it has been activated.
Specify it as active adapter. */
/* Free memory. */
return GRUB_ERR_NONE;
}
}
/* Free memory. */
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"no suitable mode found");
}
/* Initialize Video API module. */
{
}
/* Finalize Video API module. */
{
}