Browse Source

[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 11 years ago
parent
commit
11ad25933f
1 changed files with 31 additions and 11 deletions
  1. 31
    11
      src/arch/i386/interface/pcbios/vesafb.c

+ 31
- 11
src/arch/i386/interface/pcbios/vesafb.c View File

391
 /**
391
 /**
392
  * Initialise VESA frame buffer
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
  * @ret rc		Return status code
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
 	uint32_t discard_b;
398
 	uint32_t discard_b;
403
 	uint16_t *mode_numbers;
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
 	int mode_number;
406
 	int mode_number;
405
 	int rc;
407
 	int rc;
406
 
408
 
415
 		goto err_mode_list;
417
 		goto err_mode_list;
416
 
418
 
417
 	/* Select mode */
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
 		rc = mode_number;
423
 		rc = mode_number;
421
 		goto err_select_mode;
424
 		goto err_select_mode;
422
 	}
425
 	}
425
 	if ( ( rc = vesafb_set_mode ( mode_number ) ) != 0 )
428
 	if ( ( rc = vesafb_set_mode ( mode_number ) ) != 0 )
426
 		goto err_set_mode;
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
 	/* Get font data */
449
 	/* Get font data */
429
 	vesafb_font();
450
 	vesafb_font();
430
 
451
 
431
 	/* Initialise frame buffer console */
452
 	/* Initialise frame buffer console */
432
 	if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ),
453
 	if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ),
433
 				 &vesafb.pixel, &vesafb.margin, &vesafb.map,
454
 				 &vesafb.pixel, &vesafb.margin, &vesafb.map,
434
-				 &vesafb.font, pixbuf ) ) != 0 )
455
+				 &vesafb.font, config->pixbuf ) ) != 0 )
435
 		goto err_fbcon_init;
456
 		goto err_fbcon_init;
436
 
457
 
437
 	free ( mode_numbers );
458
 	free ( mode_numbers );
494
 	}
515
 	}
495
 
516
 
496
 	/* Initialise VESA frame buffer */
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
 		return rc;
519
 		return rc;
500
 
520
 
501
 	/* Mark console as enabled */
521
 	/* Mark console as enabled */

Loading…
Cancel
Save