Skip to content

Commit

Permalink
staging: xgifb: move video BIOS handling completely to ReadVBIOSTablD…
Browse files Browse the repository at this point in the history
…ata()

We need the video BIOS only on XG21 and only during the init, so let's
do everything at the same place.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Aaro Koskinen authored and Greg Kroah-Hartman committed Dec 8, 2011
1 parent c4ffaa4 commit 02a81dd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 44 deletions.
39 changes: 0 additions & 39 deletions drivers/staging/xgifb/XGI_main_26.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <linux/ioport.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/vmalloc.h>
#include <linux/vt_kern.h>
#include <linux/capability.h>
#include <linux/fs.h>
Expand All @@ -46,8 +45,6 @@
#define GPIOG_EN (1<<6)
#define GPIOG_READ (1<<1)

#define XGIFB_ROM_SIZE 65536

static char *mode;
static int vesa = -1;
static unsigned int refresh_rate;
Expand Down Expand Up @@ -1934,28 +1931,6 @@ static int __init XGIfb_setup(char *options)
return 0;
}

static unsigned char *xgifb_copy_rom(struct pci_dev *dev)
{
void __iomem *rom_address;
unsigned char *rom_copy;
size_t rom_size;

rom_address = pci_map_rom(dev, &rom_size);
if (rom_address == NULL)
return NULL;

rom_copy = vzalloc(XGIFB_ROM_SIZE);
if (rom_copy == NULL)
goto done;

rom_size = min_t(size_t, rom_size, XGIFB_ROM_SIZE);
memcpy_fromio(rom_copy, rom_address, rom_size);

done:
pci_unmap_rom(dev, rom_address);
return rom_copy;
}

static int __devinit xgifb_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
Expand Down Expand Up @@ -2041,18 +2016,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
printk("XGIfb:chipid = %x\n", xgifb_info->chip);
hw_info->jChipType = xgifb_info->chip;

if ((xgifb_info->chip == XG21) || (XGIfb_userom)) {
hw_info->pjVirtualRomBase = xgifb_copy_rom(pdev);
if (hw_info->pjVirtualRomBase)
printk(KERN_INFO "XGIfb: Video ROM found and mapped to %p\n",
hw_info->pjVirtualRomBase);
else
printk(KERN_INFO "XGIfb: Video ROM not found\n");
} else {
hw_info->pjVirtualRomBase = NULL;
printk(KERN_INFO "XGIfb: Video ROM usage disabled\n");
}

if (XGIfb_get_dram_size(xgifb_info)) {
printk(KERN_INFO "XGIfb: Fatal error: Unable to determine RAM size.\n");
ret = -ENODEV;
Expand Down Expand Up @@ -2418,7 +2381,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
error_0:
release_mem_region(xgifb_info->video_base, xgifb_info->video_size);
error:
vfree(hw_info->pjVirtualRomBase);
framebuffer_release(fb_info);
return ret;
}
Expand All @@ -2442,7 +2404,6 @@ static void __devexit xgifb_remove(struct pci_dev *pdev)
iounmap(xgifb_info->video_vbase);
release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size);
release_mem_region(xgifb_info->video_base, xgifb_info->video_size);
vfree(xgifb_info->hw_info.pjVirtualRomBase);
framebuffer_release(fb_info);
pci_set_drvdata(pdev, NULL);
}
Expand Down
44 changes: 39 additions & 5 deletions drivers/staging/xgifb/vb_init.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <linux/types.h>
#include <linux/delay.h> /* udelay */
#include <linux/pci.h>
#include <linux/vmalloc.h>

#include "vgatypes.h"
#include "XGIfb.h"
Expand Down Expand Up @@ -34,6 +35,8 @@ static const unsigned short XGINew_DDRDRAM_TYPE20[12][5] = {
{ 2, 12, 9, 8, 0x35},
{ 2, 12, 8, 4, 0x31} };

#define XGIFB_ROM_SIZE 65536

static unsigned char
XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceExtension,
struct vb_device_info *pVBInfo)
Expand Down Expand Up @@ -1091,19 +1094,49 @@ static void XGINew_SetDRAMSize_340(struct xgi_hw_device_info *HwDeviceExtension,
xgifb_reg_set(pVBInfo->P3c4, 0x21, (unsigned short) (data | 0x20));
}

static void ReadVBIOSTablData(unsigned char ChipType,
static unsigned char *xgifb_copy_rom(struct pci_dev *dev)
{
void __iomem *rom_address;
unsigned char *rom_copy;
size_t rom_size;

rom_address = pci_map_rom(dev, &rom_size);
if (rom_address == NULL)
return NULL;

rom_copy = vzalloc(XGIFB_ROM_SIZE);
if (rom_copy == NULL)
goto done;

rom_size = min_t(size_t, rom_size, XGIFB_ROM_SIZE);
memcpy_fromio(rom_copy, rom_address, rom_size);

done:
pci_unmap_rom(dev, rom_address);
return rom_copy;
}

static void ReadVBIOSTablData(struct pci_dev *pdev,
struct vb_device_info *pVBInfo)
{
unsigned char *vbios = pVBInfo->ROMAddr;
struct xgifb_video_info *xgifb_info = pci_get_drvdata(pdev);
unsigned char *vbios;
unsigned long i;
unsigned char j, k;
struct XGI21_LVDSCapStruct *lvds;

if (ChipType != XG21)
if (xgifb_info->chip != XG21)
return;
pVBInfo->IF_DEF_LVDS = 0;
if (!(vbios[0x65] & 0x1))
vbios = xgifb_copy_rom(pdev);
if (vbios == NULL) {
dev_err(&pdev->dev, "video BIOS not available\n");
return;
}
if (!(vbios[0x65] & 0x1)) {
vfree(vbios);
return;
}
pVBInfo->IF_DEF_LVDS = 1;
i = vbios[0x316] | (vbios[0x317] << 8);
j = vbios[i - 1];
Expand Down Expand Up @@ -1133,6 +1166,7 @@ static void ReadVBIOSTablData(unsigned char ChipType,
k++;
lvds++;
} while (j > 0 && k < ARRAY_SIZE(XGI21_LCDCapList));
vfree(vbios);
}

static void XGINew_ChkSenseStatus(struct xgi_hw_device_info *HwDeviceExtension,
Expand Down Expand Up @@ -1485,7 +1519,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);

/* ReadVBIOSData */
ReadVBIOSTablData(HwDeviceExtension->jChipType, pVBInfo);
ReadVBIOSTablData(pdev, pVBInfo);

/* 1.Openkey */
xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
Expand Down

0 comments on commit 02a81dd

Please sign in to comment.