drivers/xgi: Fix usage of NGI Kconfig options

This driver reinvented MAINBOARD_DO_NATIVE_VGA_INIT in a very special
way: If it wasn't set, perform native gfx init in textmode, if it was
set, perform native gfx init in linear framebuffer mode. Test for
LINEAR_FRAMEBUFFER instead and make the native gfx init optional.
Also, make Kconfig reflect the actual behaviour.

Change-Id: If20fd1f5b0f4127b426e8ff94acc61fcd4eb49af
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/20131
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Tested-by: Raptor Engineering Automated Test Stand <noreply@raptorengineeringinc.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Nico Huber 2017-06-09 18:57:07 +02:00 committed by Patrick Georgi
parent e8f6569ab3
commit a1f842d158
6 changed files with 94 additions and 96 deletions

View File

@ -1,6 +1,7 @@
config DRIVERS_XGI_Z79_COMMON
bool
select VGA
select VGA if VGA_TEXT_FRAMEBUFFER
select NO_EDID_FILL_FB
select MAINBOARD_HAS_NATIVE_VGA_INIT
select HAVE_LINEAR_FRAMEBUFFER if MAINBOARD_DO_NATIVE_VGA_INIT
select HAVE_VGA_TEXT_FRAMEBUFFER if MAINBOARD_DO_NATIVE_VGA_INIT

View File

@ -590,8 +590,6 @@ check_memory:
/* --------------------- SetMode routines ------------------------- */
#if IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT)
static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info)
{
u8 cr30 = 0, cr31 = 0;
@ -863,5 +861,3 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
}
}
}
#endif

View File

@ -65,9 +65,7 @@ static int XGIfb_crt1off;
static int XGIfb_forcecrt1 = -1;
/* global flags */
#if IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT)
static int XGIfb_tvmode;
#endif
static int enable_dstn;
// static int XGIfb_ypan = -1;
@ -384,8 +382,6 @@ static const struct _XGI_TV_filter {
{0xFF, 0xFF, 0xFF, 0xFF} } }
};
#if IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT)
static int filter = -1;
#endif
#endif

View File

@ -853,7 +853,7 @@ static void XGINew_SetDRAMSize_340(struct xgifb_video_info *xgifb_info,
pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress;
if (IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT))
if (IS_ENABLED(CONFIG_LINEAR_FRAMEBUFFER))
XGISetModeNew(xgifb_info, HwDeviceExtension, 0x2e);
data = xgifb_reg_get(pVBInfo->P3c4, 0x21);

View File

@ -119,7 +119,7 @@ int xgifb_probe(struct pci_dev *pdev, struct xgifb_video_info *xgifb_info)
xgifb_info->video_size = video_size_max;
}
if (IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT)) {
if (IS_ENABLED(CONFIG_LINEAR_FRAMEBUFFER)) {
/* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */
xgifb_reg_or(XGISR,
IND_SIS_PCI_ADDRESS_SET,
@ -263,7 +263,7 @@ int xgifb_probe(struct pci_dev *pdev, struct xgifb_video_info *xgifb_info)
xgifb_info->mode_idx =
XGIfb_GetXG21DefaultLVDSModeIdx(xgifb_info);
else
if (IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT))
if (IS_ENABLED(CONFIG_LINEAR_FRAMEBUFFER))
xgifb_info->mode_idx = DEFAULT_MODE;
else
xgifb_info->mode_idx = DEFAULT_TEXT_MODE;
@ -338,85 +338,88 @@ int xgifb_modeset(struct pci_dev *pdev, struct xgifb_video_info *xgifb_info)
hw_info = &xgifb_info->hw_info;
#if IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT)
/* Set mode */
XGIfb_pre_setmode(xgifb_info);
if (XGISetModeNew(xgifb_info, hw_info,
XGIbios_mode[xgifb_info->mode_idx].mode_no)
== 0) {
pr_err("Setting mode[0x%x] failed\n",
XGIbios_mode[xgifb_info->mode_idx].mode_no);
return -22;
if (IS_ENABLED(CONFIG_LINEAR_FRAMEBUFFER)) {
/* Set mode */
XGIfb_pre_setmode(xgifb_info);
if (XGISetModeNew(xgifb_info, hw_info,
XGIbios_mode[xgifb_info->mode_idx].mode_no)
== 0) {
pr_err("Setting mode[0x%x] failed\n",
XGIbios_mode[xgifb_info->mode_idx].mode_no);
return -22;
}
xgifb_info->video_linelength =
xgifb_info->video_width *
(xgifb_info->video_bpp >> 3);
xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD);
xgifb_reg_set(XGICR, 0x13,
(xgifb_info->video_linelength & 0x00ff));
xgifb_reg_set(XGISR, 0x0e,
(xgifb_info->video_linelength & 0xff00) >> 8);
XGIfb_post_setmode(xgifb_info);
pr_debug("Set new mode: %dx%dx%d-%d\n",
XGIbios_mode[xgifb_info->mode_idx].xres,
XGIbios_mode[xgifb_info->mode_idx].yres,
XGIbios_mode[xgifb_info->mode_idx].bpp,
xgifb_info->refresh_rate);
/* Set LinuxBIOS framebuffer information */
xgi_vbe_valid = 1;
xgi_fb.physical_address = xgifb_info->video_base;
xgi_fb.x_resolution = xgifb_info->video_width;
xgi_fb.y_resolution = xgifb_info->video_height;
xgi_fb.bytes_per_line =
xgifb_info->video_width * xgifb_info->video_bpp;
xgi_fb.bits_per_pixel = xgifb_info->video_bpp;
xgi_fb.reserved_mask_pos = 0;
xgi_fb.reserved_mask_size = 0;
switch(xgifb_info->video_bpp){
case 32:
case 24:
/* packed into 4-byte words */
xgi_fb.reserved_mask_pos = 24;
xgi_fb.reserved_mask_size = 8;
xgi_fb.red_mask_pos = 16;
xgi_fb.red_mask_size = 8;
xgi_fb.green_mask_pos = 8;
xgi_fb.green_mask_size = 8;
xgi_fb.blue_mask_pos = 0;
xgi_fb.blue_mask_size = 8;
break;
case 16:
/* packed into 2-byte words */
xgi_fb.red_mask_pos = 11;
xgi_fb.red_mask_size = 5;
xgi_fb.green_mask_pos = 5;
xgi_fb.green_mask_size = 6;
xgi_fb.blue_mask_pos = 0;
xgi_fb.blue_mask_size = 5;
break;
default:
printk(BIOS_SPEW, "%s: unsupported BPP %d\n", __func__,
xgifb_info->video_bpp);
xgi_vbe_valid = 0;
}
} else {
/*
* FIXME
* Text mode is slightly unstable/jittery
* (bad/incomplete DDR init?)
*/
/* Initialize standard VGA text mode */
vga_io_init();
vga_textmode_init();
printk(BIOS_INFO, "XGI VGA text mode initialized\n");
/* if we don't have console, at least print something... */
vga_line_write(0, "XGI VGA text mode initialized");
}
xgifb_info->video_linelength =
xgifb_info->video_width *
(xgifb_info->video_bpp >> 3);
xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD);
xgifb_reg_set(XGICR, 0x13, (xgifb_info->video_linelength & 0x00ff));
xgifb_reg_set(XGISR,
0x0E,
(xgifb_info->video_linelength & 0xff00) >> 8);
XGIfb_post_setmode(xgifb_info);
pr_debug("Set new mode: %dx%dx%d-%d\n",
XGIbios_mode[xgifb_info->mode_idx].xres,
XGIbios_mode[xgifb_info->mode_idx].yres,
XGIbios_mode[xgifb_info->mode_idx].bpp,
xgifb_info->refresh_rate);
/* Set LinuxBIOS framebuffer information */
xgi_vbe_valid = 1;
xgi_fb.physical_address = xgifb_info->video_base;
xgi_fb.x_resolution = xgifb_info->video_width;
xgi_fb.y_resolution = xgifb_info->video_height;
xgi_fb.bytes_per_line = xgifb_info->video_width * xgifb_info->video_bpp;
xgi_fb.bits_per_pixel = xgifb_info->video_bpp;
xgi_fb.reserved_mask_pos = 0;
xgi_fb.reserved_mask_size = 0;
switch(xgifb_info->video_bpp){
case 32:
case 24:
/* packed into 4-byte words */
xgi_fb.reserved_mask_pos = 24;
xgi_fb.reserved_mask_size = 8;
xgi_fb.red_mask_pos = 16;
xgi_fb.red_mask_size = 8;
xgi_fb.green_mask_pos = 8;
xgi_fb.green_mask_size = 8;
xgi_fb.blue_mask_pos = 0;
xgi_fb.blue_mask_size = 8;
break;
case 16:
/* packed into 2-byte words */
xgi_fb.red_mask_pos = 11;
xgi_fb.red_mask_size = 5;
xgi_fb.green_mask_pos = 5;
xgi_fb.green_mask_size = 6;
xgi_fb.blue_mask_pos = 0;
xgi_fb.blue_mask_size = 5;
break;
default:
printk(BIOS_SPEW, "%s: unsupported BPP %d\n", __func__,
xgifb_info->video_bpp);
xgi_vbe_valid = 0;
}
#else
/* FIXME
* Text mode is slightly unstable/jittery (bad/incomplete DDR init?)
*/
/* Initialize standard VGA text mode */
vga_io_init();
vga_textmode_init();
printk(BIOS_INFO, "XGI VGA text mode initialized\n");
/* if we don't have console, at least print something... */
vga_line_write(0, "XGI VGA text mode initialized");
#endif
return 0;
}

View File

@ -40,12 +40,14 @@ static void xgi_z9s_init(struct device *dev)
u8 ret;
struct xgifb_video_info *xgifb_info;
printk(BIOS_INFO, "XGI Z9s: initializing video device\n");
xgifb_info = malloc(sizeof(*xgifb_info));
ret = xgifb_probe(dev, xgifb_info);
if (!ret)
xgifb_modeset(dev, xgifb_info);
free(xgifb_info);
if (IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT)) {
printk(BIOS_INFO, "XGI Z9s: initializing video device\n");
xgifb_info = malloc(sizeof(*xgifb_info));
ret = xgifb_probe(dev, xgifb_info);
if (!ret)
xgifb_modeset(dev, xgifb_info);
free(xgifb_info);
}
}
static struct device_operations xgi_z9s_ops = {