|
@@ -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 */
|