Quellcode durchsuchen

[vesafb] Allow for an arbitrary margin around the text area

Allow for an arbitrary margin to be specified in the console
configuration.  If the actual screen size does not match the requested
screen size, then update any margins specified so that they remain in
the same place relative to the requested screen size.  If margins are
unspecified (i.e. zero), then leave them as zero.

The underlying assumption here is that any specified margins are
likely to describe an area within a background picture, and so should
remain in the same place relative to that background picture.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown vor 10 Jahren
Ursprung
Commit
11ad25933f
1 geänderte Dateien mit 31 neuen und 11 gelöschten Zeilen
  1. 31
    11
      src/arch/i386/interface/pcbios/vesafb.c

+ 31
- 11
src/arch/i386/interface/pcbios/vesafb.c Datei anzeigen

@@ -391,16 +391,18 @@ static void vesafb_restore ( void ) {
391 391
 /**
392 392
  * Initialise VESA frame buffer
393 393
  *
394
- * @v min_width		Minimum required width (in pixels)
395
- * @v min_height	Minimum required height (in pixels)
396
- * @v min_bpp		Minimum required colour depth (in bits per pixel)
397
- * @v pixbuf		Background picture (if any)
394
+ * @v config		Console configuration, or NULL to reset
398 395
  * @ret rc		Return status code
399 396
  */
400
-static int vesafb_init ( unsigned int min_width, unsigned int min_height,
401
-			 unsigned int min_bpp, struct pixel_buffer *pixbuf ) {
397
+static int vesafb_init ( struct console_configuration *config ) {
402 398
 	uint32_t discard_b;
403 399
 	uint16_t *mode_numbers;
400
+	unsigned int xgap;
401
+	unsigned int ygap;
402
+	unsigned int left;
403
+	unsigned int right;
404
+	unsigned int top;
405
+	unsigned int bottom;
404 406
 	int mode_number;
405 407
 	int rc;
406 408
 
@@ -415,8 +417,9 @@ static int vesafb_init ( unsigned int min_width, unsigned int min_height,
415 417
 		goto err_mode_list;
416 418
 
417 419
 	/* Select mode */
418
-	if ( ( mode_number = vesafb_select_mode ( mode_numbers, min_width,
419
-						  min_height, min_bpp ) ) < 0 ){
420
+	if ( ( mode_number = vesafb_select_mode ( mode_numbers, config->width,
421
+						  config->height,
422
+						  config->bpp ) ) < 0 ) {
420 423
 		rc = mode_number;
421 424
 		goto err_select_mode;
422 425
 	}
@@ -425,13 +428,31 @@ static int vesafb_init ( unsigned int min_width, unsigned int min_height,
425 428
 	if ( ( rc = vesafb_set_mode ( mode_number ) ) != 0 )
426 429
 		goto err_set_mode;
427 430
 
431
+	/* Calculate margin.  If the actual screen size is larger than
432
+	 * the requested screen size, then update the margins so that
433
+	 * the margin remains relative to the requested screen size.
434
+	 * (As an exception, if a zero margin was specified then treat
435
+	 * this as meaning "expand to edge of actual screen".)
436
+	 */
437
+	xgap = ( vesafb.pixel.width - config->width );
438
+	ygap = ( vesafb.pixel.height - config->height );
439
+	left = ( xgap / 2 );
440
+	right = ( xgap - left );
441
+	top = ( ygap / 2 );
442
+	bottom = ( ygap - top );
443
+	vesafb.margin.left = ( config->left + ( config->left ? left : 0 ) );
444
+	vesafb.margin.right = ( config->right + ( config->right ? right : 0 ) );
445
+	vesafb.margin.top = ( config->top + ( config->top ? top : 0 ) );
446
+	vesafb.margin.bottom =
447
+		( config->bottom + ( config->bottom ? bottom : 0 ) );
448
+
428 449
 	/* Get font data */
429 450
 	vesafb_font();
430 451
 
431 452
 	/* Initialise frame buffer console */
432 453
 	if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ),
433 454
 				 &vesafb.pixel, &vesafb.margin, &vesafb.map,
434
-				 &vesafb.font, pixbuf ) ) != 0 )
455
+				 &vesafb.font, config->pixbuf ) ) != 0 )
435 456
 		goto err_fbcon_init;
436 457
 
437 458
 	free ( mode_numbers );
@@ -494,8 +515,7 @@ static int vesafb_configure ( struct console_configuration *config ) {
494 515
 	}
495 516
 
496 517
 	/* Initialise VESA frame buffer */
497
-	if ( ( rc = vesafb_init ( config->width, config->height, config->bpp,
498
-				  config->pixbuf ) ) != 0 )
518
+	if ( ( rc = vesafb_init ( config ) ) != 0 )
499 519
 		return rc;
500 520
 
501 521
 	/* Mark console as enabled */

Laden…
Abbrechen
Speichern