2010-05-19 02:44:14 -06:00
|
|
|
/*
|
|
|
|
* XG20, XG21, XG40, XG42 frame buffer device
|
|
|
|
* for Linux kernels 2.5.x, 2.6.x
|
|
|
|
* Base on TW's sis fbdev code.
|
|
|
|
*/
|
|
|
|
|
2012-01-22 01:48:25 -07:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2012-09-12 15:45:42 -06:00
|
|
|
#include <linux/sizes.h>
|
2010-05-19 02:44:14 -06:00
|
|
|
#include <linux/module.h>
|
staging: xgifb: use arch_phys_wc_add() and ioremap_wc()
The same area used for ioremap() is used for the MTRR area.
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.
There are a few motivations for this:
a) Take advantage of PAT when available
b) Help bury MTRR code away, MTRR is architecture specific and on
x86 its replaced by PAT
c) Help with the goal of eventually using _PAGE_CACHE_UC over
_PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
de33c442e titled "x86 PAT: fix performance drop for glx,
use UC minus for ioremap(), ioremap_nocache() and
pci_mmap_page_range()")
The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.
@ mtrr_found @
expression index, base, size;
@@
-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);
@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@
-mtrr_del(index, base, size);
+arch_phys_wc_del(index);
@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@
-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);
@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@
-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);
@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);
@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);
Generated-by: Coccinelle SmPL
Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Brian Vandre <bvandre@gmail.com>
Cc: Thomas Gummerer <t.gummerer@gmail.com>
Cc: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
Cc: Lubomir Rintel <lkundrak@v3.sk>
Cc: Vitor Braga <vitorpybraga@gmail.com>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: devel@driverdev.osuosl.org
Cc: linux-fbdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-28 13:39:07 -06:00
|
|
|
#include <linux/pci.h>
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
#include "XGI_main.h"
|
2011-04-18 13:14:06 -06:00
|
|
|
#include "vb_init.h"
|
2010-05-19 02:44:14 -06:00
|
|
|
#include "vb_util.h"
|
2011-04-18 13:14:06 -06:00
|
|
|
#include "vb_setmode.h"
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
#define Index_CR_GPIO_Reg1 0x48
|
|
|
|
#define Index_CR_GPIO_Reg3 0x4a
|
|
|
|
|
|
|
|
#define GPIOG_EN (1<<6)
|
|
|
|
#define GPIOG_READ (1<<1)
|
|
|
|
|
2011-12-05 15:10:49 -07:00
|
|
|
static char *forcecrt2type;
|
2011-08-29 14:14:25 -06:00
|
|
|
static char *mode;
|
2011-08-29 14:14:32 -06:00
|
|
|
static int vesa = -1;
|
2011-10-11 12:47:17 -06:00
|
|
|
static unsigned int refresh_rate;
|
2011-08-29 14:14:25 -06:00
|
|
|
|
2010-05-19 02:44:14 -06:00
|
|
|
/* -------------------- Macro definitions ---------------------------- */
|
|
|
|
|
2012-06-18 05:12:02 -06:00
|
|
|
#ifdef DEBUG
|
2010-05-19 02:44:14 -06:00
|
|
|
static void dumpVGAReg(void)
|
|
|
|
{
|
2010-09-06 06:04:26 -06:00
|
|
|
u8 i, reg;
|
|
|
|
|
2011-04-18 13:13:59 -06:00
|
|
|
xgifb_reg_set(XGISR, 0x05, 0x86);
|
2010-09-06 06:04:26 -06:00
|
|
|
|
|
|
|
for (i = 0; i < 0x4f; i++) {
|
2011-04-18 13:13:58 -06:00
|
|
|
reg = xgifb_reg_get(XGISR, i);
|
2012-07-06 04:40:40 -06:00
|
|
|
pr_debug("o 3c4 %x\n", i);
|
|
|
|
pr_debug("i 3c5 => %x\n", reg);
|
2010-09-06 06:04:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 0xF0; i++) {
|
2011-04-18 13:13:58 -06:00
|
|
|
reg = xgifb_reg_get(XGICR, i);
|
2012-07-06 04:40:40 -06:00
|
|
|
pr_debug("o 3d4 %x\n", i);
|
|
|
|
pr_debug("i 3d5 => %x\n", reg);
|
2010-09-06 06:04:26 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
#else
|
2010-09-06 06:04:26 -06:00
|
|
|
static inline void dumpVGAReg(void)
|
|
|
|
{
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* --------------- Hardware Access Routines -------------------------- */
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
static int XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr,
|
|
|
|
struct xgi_hw_device_info *HwDeviceExtension,
|
2013-07-16 14:13:25 -06:00
|
|
|
unsigned char modeno)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2010-09-06 06:04:26 -06:00
|
|
|
unsigned short ModeNo = modeno;
|
|
|
|
unsigned short ModeIdIndex = 0, ClockIndex = 0;
|
|
|
|
unsigned short RefreshRateTableIndex = 0;
|
|
|
|
int Clock;
|
2014-03-29 21:44:59 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2013-07-16 14:13:30 -06:00
|
|
|
XGI_SearchModeID(ModeNo, &ModeIdIndex);
|
2012-04-06 16:13:50 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
|
|
|
|
ModeIdIndex, XGI_Pr);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:53 -07:00
|
|
|
ClockIndex = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
|
2010-09-06 06:04:26 -06:00
|
|
|
|
2012-11-04 12:14:58 -07:00
|
|
|
Clock = XGI_VCLKData[ClockIndex].CLOCK * 1000;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
return Clock;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
|
|
|
|
struct xgi_hw_device_info *HwDeviceExtension,
|
2013-07-16 14:13:25 -06:00
|
|
|
unsigned char modeno,
|
2010-09-06 06:04:26 -06:00
|
|
|
u32 *left_margin, u32 *right_margin, u32 *upper_margin,
|
|
|
|
u32 *lower_margin, u32 *hsync_len, u32 *vsync_len, u32 *sync,
|
|
|
|
u32 *vmode)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2010-09-06 06:04:26 -06:00
|
|
|
unsigned short ModeNo = modeno;
|
2012-04-06 16:13:48 -06:00
|
|
|
unsigned short ModeIdIndex, index = 0;
|
2010-09-06 06:04:26 -06:00
|
|
|
unsigned short RefreshRateTableIndex = 0;
|
|
|
|
|
2013-02-02 20:08:41 -07:00
|
|
|
unsigned short VRE, VBE, VRS, VDE;
|
|
|
|
unsigned short HRE, HBE, HRS, HDE;
|
2010-09-06 06:04:26 -06:00
|
|
|
unsigned char sr_data, cr_data, cr_data2;
|
2013-02-03 14:54:36 -07:00
|
|
|
int B, C, D, F, temp, j;
|
2014-03-29 21:44:59 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr);
|
2013-07-16 14:13:30 -06:00
|
|
|
if (!XGI_SearchModeID(ModeNo, &ModeIdIndex))
|
2012-04-06 16:13:48 -06:00
|
|
|
return 0;
|
2010-09-06 06:04:26 -06:00
|
|
|
RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
|
|
|
|
ModeIdIndex, XGI_Pr);
|
2012-11-04 12:14:53 -07:00
|
|
|
index = XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:54 -07:00
|
|
|
sr_data = XGI_CRT1Table[index].CR[5];
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2015-03-03 22:35:48 -07:00
|
|
|
HDE = XGI330_RefIndex[RefreshRateTableIndex].XRes >> 3;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:54 -07:00
|
|
|
cr_data = XGI_CRT1Table[index].CR[3];
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
/* Horizontal retrace (=sync) start */
|
|
|
|
HRS = (cr_data & 0xff) | ((unsigned short) (sr_data & 0xC0) << 2);
|
2013-02-03 14:54:36 -07:00
|
|
|
F = HRS - HDE - 3;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:54 -07:00
|
|
|
sr_data = XGI_CRT1Table[index].CR[6];
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:54 -07:00
|
|
|
cr_data = XGI_CRT1Table[index].CR[2];
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:54 -07:00
|
|
|
cr_data2 = XGI_CRT1Table[index].CR[4];
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
/* Horizontal blank end */
|
|
|
|
HBE = (cr_data & 0x1f) | ((unsigned short) (cr_data2 & 0x80) >> 2)
|
|
|
|
| ((unsigned short) (sr_data & 0x03) << 6);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
/* Horizontal retrace (=sync) end */
|
|
|
|
HRE = (cr_data2 & 0x1f) | ((sr_data & 0x04) << 3);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2013-02-03 14:54:36 -07:00
|
|
|
temp = HBE - ((HDE - 1) & 255);
|
2010-09-06 06:04:26 -06:00
|
|
|
B = (temp > 0) ? temp : (temp + 256);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2013-02-03 14:54:36 -07:00
|
|
|
temp = HRE - ((HDE + F + 3) & 63);
|
2010-09-06 06:04:26 -06:00
|
|
|
C = (temp > 0) ? temp : (temp + 64);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
D = B - F - C;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
*left_margin = D * 8;
|
|
|
|
*right_margin = F * 8;
|
|
|
|
*hsync_len = C * 8;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:54 -07:00
|
|
|
sr_data = XGI_CRT1Table[index].CR[14];
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:54 -07:00
|
|
|
cr_data2 = XGI_CRT1Table[index].CR[9];
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2013-02-03 14:54:36 -07:00
|
|
|
VDE = XGI330_RefIndex[RefreshRateTableIndex].YRes;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:54 -07:00
|
|
|
cr_data = XGI_CRT1Table[index].CR[10];
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
/* Vertical retrace (=sync) start */
|
|
|
|
VRS = (cr_data & 0xff) | ((unsigned short) (cr_data2 & 0x04) << 6)
|
|
|
|
| ((unsigned short) (cr_data2 & 0x80) << 2)
|
|
|
|
| ((unsigned short) (sr_data & 0x08) << 7);
|
2013-02-03 14:54:36 -07:00
|
|
|
F = VRS + 1 - VDE;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:54 -07:00
|
|
|
cr_data = XGI_CRT1Table[index].CR[13];
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
/* Vertical blank end */
|
|
|
|
VBE = (cr_data & 0xff) | ((unsigned short) (sr_data & 0x10) << 4);
|
2013-02-03 14:54:36 -07:00
|
|
|
temp = VBE - ((VDE - 1) & 511);
|
2010-09-06 06:04:26 -06:00
|
|
|
B = (temp > 0) ? temp : (temp + 512);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:54 -07:00
|
|
|
cr_data = XGI_CRT1Table[index].CR[11];
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
/* Vertical retrace (=sync) end */
|
|
|
|
VRE = (cr_data & 0x0f) | ((sr_data & 0x20) >> 1);
|
2013-02-03 14:54:36 -07:00
|
|
|
temp = VRE - ((VDE + F - 1) & 31);
|
2010-09-06 06:04:26 -06:00
|
|
|
C = (temp > 0) ? temp : (temp + 32);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
D = B - F - C;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
*upper_margin = D;
|
|
|
|
*lower_margin = F;
|
|
|
|
*vsync_len = C;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:53 -07:00
|
|
|
if (XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x8000)
|
2010-09-06 06:04:26 -06:00
|
|
|
*sync &= ~FB_SYNC_VERT_HIGH_ACT;
|
|
|
|
else
|
|
|
|
*sync |= FB_SYNC_VERT_HIGH_ACT;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-11-04 12:14:53 -07:00
|
|
|
if (XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x4000)
|
2010-09-06 06:04:26 -06:00
|
|
|
*sync &= ~FB_SYNC_HOR_HIGH_ACT;
|
|
|
|
else
|
|
|
|
*sync |= FB_SYNC_HOR_HIGH_ACT;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
*vmode = FB_VMODE_NONINTERLACED;
|
2012-11-04 12:14:53 -07:00
|
|
|
if (XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag & 0x0080)
|
2010-09-06 06:04:26 -06:00
|
|
|
*vmode = FB_VMODE_INTERLACED;
|
|
|
|
else {
|
|
|
|
j = 0;
|
2012-11-04 12:14:52 -07:00
|
|
|
while (XGI330_EModeIDTable[j].Ext_ModeID != 0xff) {
|
|
|
|
if (XGI330_EModeIDTable[j].Ext_ModeID ==
|
2012-11-04 12:14:53 -07:00
|
|
|
XGI330_RefIndex[RefreshRateTableIndex].ModeID) {
|
2012-11-04 12:14:52 -07:00
|
|
|
if (XGI330_EModeIDTable[j].Ext_ModeFlag &
|
2011-04-25 22:13:43 -06:00
|
|
|
DoubleScanMode) {
|
2010-09-06 06:04:26 -06:00
|
|
|
*vmode = FB_VMODE_DOUBLE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
return 1;
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2013-01-20 17:57:47 -07:00
|
|
|
void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2010-09-06 06:04:26 -06:00
|
|
|
XGI_Pr->P3c4 = BaseAddr + 0x14;
|
|
|
|
XGI_Pr->P3d4 = BaseAddr + 0x24;
|
|
|
|
XGI_Pr->P3c0 = BaseAddr + 0x10;
|
|
|
|
XGI_Pr->P3ce = BaseAddr + 0x1e;
|
|
|
|
XGI_Pr->P3c2 = BaseAddr + 0x12;
|
2013-02-07 09:45:40 -07:00
|
|
|
XGI_Pr->P3cc = BaseAddr + 0x1c;
|
2010-09-06 06:04:26 -06:00
|
|
|
XGI_Pr->P3ca = BaseAddr + 0x1a;
|
|
|
|
XGI_Pr->P3c6 = BaseAddr + 0x16;
|
|
|
|
XGI_Pr->P3c7 = BaseAddr + 0x17;
|
|
|
|
XGI_Pr->P3c8 = BaseAddr + 0x18;
|
|
|
|
XGI_Pr->P3c9 = BaseAddr + 0x19;
|
|
|
|
XGI_Pr->P3da = BaseAddr + 0x2A;
|
2014-05-18 04:55:14 -06:00
|
|
|
XGI_Pr->Part0Port = BaseAddr + XGI_CRT2_PORT_00;
|
2011-04-25 22:13:43 -06:00
|
|
|
/* Digital video interface registers (LCD) */
|
2012-02-09 13:11:46 -07:00
|
|
|
XGI_Pr->Part1Port = BaseAddr + SIS_CRT2_PORT_04;
|
2011-04-25 22:13:43 -06:00
|
|
|
/* 301 TV Encoder registers */
|
2012-02-09 13:11:46 -07:00
|
|
|
XGI_Pr->Part2Port = BaseAddr + SIS_CRT2_PORT_10;
|
2011-04-25 22:13:43 -06:00
|
|
|
/* 301 Macrovision registers */
|
2012-02-09 13:11:46 -07:00
|
|
|
XGI_Pr->Part3Port = BaseAddr + SIS_CRT2_PORT_12;
|
2011-04-25 22:13:43 -06:00
|
|
|
/* 301 VGA2 (and LCD) registers */
|
2012-02-09 13:11:46 -07:00
|
|
|
XGI_Pr->Part4Port = BaseAddr + SIS_CRT2_PORT_14;
|
2011-04-25 22:13:43 -06:00
|
|
|
/* 301 palette address port registers */
|
2012-02-09 13:11:46 -07:00
|
|
|
XGI_Pr->Part5Port = BaseAddr + SIS_CRT2_PORT_14 + 2;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------ Internal helper routines ----------------- */
|
|
|
|
|
2011-12-05 15:10:45 -07:00
|
|
|
static int XGIfb_GetXG21DefaultLVDSModeIdx(struct xgifb_video_info *xgifb_info)
|
2011-04-18 13:14:05 -06:00
|
|
|
{
|
2012-07-06 04:40:42 -06:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while ((XGIbios_mode[i].mode_no != 0)
|
|
|
|
&& (XGIbios_mode[i].xres <= xgifb_info->lvds_data.LVDSHDE)) {
|
|
|
|
if ((XGIbios_mode[i].xres == xgifb_info->lvds_data.LVDSHDE)
|
|
|
|
&& (XGIbios_mode[i].yres == xgifb_info->lvds_data.LVDSVDE)
|
|
|
|
&& (XGIbios_mode[i].bpp == 8)) {
|
|
|
|
return i;
|
2011-04-18 13:14:05 -06:00
|
|
|
}
|
2012-07-06 04:40:42 -06:00
|
|
|
i++;
|
2011-04-18 13:14:05 -06:00
|
|
|
}
|
|
|
|
|
2012-07-06 04:40:42 -06:00
|
|
|
return -1;
|
2011-04-18 13:14:05 -06:00
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
static void XGIfb_search_mode(struct xgifb_video_info *xgifb_info,
|
|
|
|
const char *name)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2012-04-06 16:13:55 -06:00
|
|
|
unsigned int xres;
|
|
|
|
unsigned int yres;
|
|
|
|
unsigned int bpp;
|
|
|
|
int i;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-04-06 16:13:55 -06:00
|
|
|
if (sscanf(name, "%ux%ux%u", &xres, &yres, &bpp) != 3)
|
|
|
|
goto invalid_mode;
|
|
|
|
|
|
|
|
if (bpp == 24)
|
|
|
|
bpp = 32; /* That's for people who mix up color and fb depth. */
|
|
|
|
|
|
|
|
for (i = 0; XGIbios_mode[i].mode_no != 0; i++)
|
|
|
|
if (XGIbios_mode[i].xres == xres &&
|
|
|
|
XGIbios_mode[i].yres == yres &&
|
|
|
|
XGIbios_mode[i].bpp == bpp) {
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->mode_idx = i;
|
2012-04-06 16:13:55 -06:00
|
|
|
return;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
2012-04-06 16:13:55 -06:00
|
|
|
invalid_mode:
|
|
|
|
pr_info("Invalid mode '%s'\n", name);
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
static void XGIfb_search_vesamode(struct xgifb_video_info *xgifb_info,
|
|
|
|
unsigned int vesamode)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2012-07-06 04:40:43 -06:00
|
|
|
int i = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-08-29 14:14:32 -06:00
|
|
|
if (vesamode == 0)
|
|
|
|
goto invalid;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
vesamode &= 0x1dff; /* Clean VESA mode number from other flags */
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
while (XGIbios_mode[i].mode_no != 0) {
|
2011-04-25 22:13:43 -06:00
|
|
|
if ((XGIbios_mode[i].vesa_mode_no_1 == vesamode) ||
|
|
|
|
(XGIbios_mode[i].vesa_mode_no_2 == vesamode)) {
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->mode_idx = i;
|
2012-07-06 04:40:43 -06:00
|
|
|
return;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2011-08-29 14:14:32 -06:00
|
|
|
|
|
|
|
invalid:
|
2012-07-06 04:40:43 -06:00
|
|
|
pr_info("Invalid VESA mode 0x%x'\n", vesamode);
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
static int XGIfb_validate_mode(struct xgifb_video_info *xgifb_info, int myindex)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2010-09-06 06:04:26 -06:00
|
|
|
u16 xres, yres;
|
2011-10-11 12:47:19 -06:00
|
|
|
struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info;
|
2012-09-11 15:44:37 -06:00
|
|
|
unsigned long required_mem;
|
2010-09-06 06:04:26 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->chip == XG21) {
|
2011-10-11 12:47:37 -06:00
|
|
|
if (xgifb_info->display2 == XGIFB_DISP_LCD) {
|
2011-12-05 15:10:45 -07:00
|
|
|
xres = xgifb_info->lvds_data.LVDSHDE;
|
|
|
|
yres = xgifb_info->lvds_data.LVDSVDE;
|
2010-09-06 06:04:26 -06:00
|
|
|
if (XGIbios_mode[myindex].xres > xres)
|
|
|
|
return -1;
|
|
|
|
if (XGIbios_mode[myindex].yres > yres)
|
|
|
|
return -1;
|
2011-04-25 22:13:43 -06:00
|
|
|
if ((XGIbios_mode[myindex].xres < xres) &&
|
|
|
|
(XGIbios_mode[myindex].yres < yres)) {
|
2010-09-06 06:04:26 -06:00
|
|
|
if (XGIbios_mode[myindex].bpp > 8)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-09-11 15:44:37 -06:00
|
|
|
goto check_memory;
|
2010-09-06 06:04:26 -06:00
|
|
|
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
2010-09-06 06:04:26 -06:00
|
|
|
|
|
|
|
/* FIXME: for now, all is valid on XG27 */
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->chip == XG27)
|
2012-09-11 15:44:37 -06:00
|
|
|
goto check_memory;
|
2010-09-06 06:04:26 -06:00
|
|
|
|
|
|
|
if (!(XGIbios_mode[myindex].chipset & MD_XGI315))
|
|
|
|
return -1;
|
|
|
|
|
2011-10-11 12:47:37 -06:00
|
|
|
switch (xgifb_info->display2) {
|
|
|
|
case XGIFB_DISP_LCD:
|
2011-10-11 12:47:15 -06:00
|
|
|
switch (hw_info->ulCRT2LCDType) {
|
2010-09-06 06:04:26 -06:00
|
|
|
case LCD_640x480:
|
|
|
|
xres = 640;
|
|
|
|
yres = 480;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case LCD_800x600:
|
|
|
|
xres = 800;
|
|
|
|
yres = 600;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case LCD_1024x600:
|
|
|
|
xres = 1024;
|
|
|
|
yres = 600;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case LCD_1024x768:
|
|
|
|
xres = 1024;
|
|
|
|
yres = 768;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case LCD_1152x768:
|
|
|
|
xres = 1152;
|
|
|
|
yres = 768;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case LCD_1280x960:
|
|
|
|
xres = 1280;
|
|
|
|
yres = 960;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case LCD_1280x768:
|
|
|
|
xres = 1280;
|
|
|
|
yres = 768;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case LCD_1280x1024:
|
|
|
|
xres = 1280;
|
|
|
|
yres = 1024;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case LCD_1400x1050:
|
|
|
|
xres = 1400;
|
|
|
|
yres = 1050;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case LCD_1600x1200:
|
|
|
|
xres = 1600;
|
|
|
|
yres = 1200;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
xres = 0;
|
|
|
|
yres = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (XGIbios_mode[myindex].xres > xres)
|
|
|
|
return -1;
|
|
|
|
if (XGIbios_mode[myindex].yres > yres)
|
|
|
|
return -1;
|
2011-10-11 12:47:15 -06:00
|
|
|
if ((hw_info->ulExternalChip == 0x01) || /* LVDS */
|
|
|
|
(hw_info->ulExternalChip == 0x05)) { /* LVDS+Chrontel */
|
2010-09-06 06:04:26 -06:00
|
|
|
switch (XGIbios_mode[myindex].xres) {
|
|
|
|
case 512:
|
|
|
|
if (XGIbios_mode[myindex].yres != 512)
|
|
|
|
return -1;
|
2011-10-11 12:47:15 -06:00
|
|
|
if (hw_info->ulCRT2LCDType == LCD_1024x600)
|
2010-09-06 06:04:26 -06:00
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 640:
|
|
|
|
if ((XGIbios_mode[myindex].yres != 400)
|
|
|
|
&& (XGIbios_mode[myindex].yres
|
|
|
|
!= 480))
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 800:
|
|
|
|
if (XGIbios_mode[myindex].yres != 600)
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 1024:
|
2011-04-25 22:13:43 -06:00
|
|
|
if ((XGIbios_mode[myindex].yres != 600) &&
|
|
|
|
(XGIbios_mode[myindex].yres != 768))
|
2010-09-06 06:04:26 -06:00
|
|
|
return -1;
|
2011-04-25 22:13:43 -06:00
|
|
|
if ((XGIbios_mode[myindex].yres == 600) &&
|
2011-10-11 12:47:15 -06:00
|
|
|
(hw_info->ulCRT2LCDType != LCD_1024x600))
|
2010-09-06 06:04:26 -06:00
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 1152:
|
|
|
|
if ((XGIbios_mode[myindex].yres) != 768)
|
|
|
|
return -1;
|
2011-10-11 12:47:15 -06:00
|
|
|
if (hw_info->ulCRT2LCDType != LCD_1152x768)
|
2010-09-06 06:04:26 -06:00
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 1280:
|
2011-04-25 22:13:43 -06:00
|
|
|
if ((XGIbios_mode[myindex].yres != 768) &&
|
|
|
|
(XGIbios_mode[myindex].yres != 1024))
|
2010-09-06 06:04:26 -06:00
|
|
|
return -1;
|
2011-04-25 22:13:43 -06:00
|
|
|
if ((XGIbios_mode[myindex].yres == 768) &&
|
2011-10-11 12:47:15 -06:00
|
|
|
(hw_info->ulCRT2LCDType != LCD_1280x768))
|
2010-09-06 06:04:26 -06:00
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 1400:
|
|
|
|
if (XGIbios_mode[myindex].yres != 1050)
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 1600:
|
|
|
|
if (XGIbios_mode[myindex].yres != 1200)
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -1;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
2010-09-06 06:04:26 -06:00
|
|
|
} else {
|
|
|
|
switch (XGIbios_mode[myindex].xres) {
|
|
|
|
case 512:
|
|
|
|
if (XGIbios_mode[myindex].yres != 512)
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 640:
|
2011-04-25 22:13:43 -06:00
|
|
|
if ((XGIbios_mode[myindex].yres != 400) &&
|
|
|
|
(XGIbios_mode[myindex].yres != 480))
|
2010-09-06 06:04:26 -06:00
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 800:
|
|
|
|
if (XGIbios_mode[myindex].yres != 600)
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 1024:
|
|
|
|
if (XGIbios_mode[myindex].yres != 768)
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 1280:
|
2011-04-25 22:13:43 -06:00
|
|
|
if ((XGIbios_mode[myindex].yres != 960) &&
|
|
|
|
(XGIbios_mode[myindex].yres != 1024))
|
2010-09-06 06:04:26 -06:00
|
|
|
return -1;
|
|
|
|
if (XGIbios_mode[myindex].yres == 960) {
|
2011-10-11 12:47:15 -06:00
|
|
|
if (hw_info->ulCRT2LCDType ==
|
2011-04-25 22:13:43 -06:00
|
|
|
LCD_1400x1050)
|
2010-09-06 06:04:26 -06:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1400:
|
|
|
|
if (XGIbios_mode[myindex].yres != 1050)
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case 1600:
|
|
|
|
if (XGIbios_mode[myindex].yres != 1200)
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -1;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-10-11 12:47:37 -06:00
|
|
|
case XGIFB_DISP_TV:
|
2010-09-06 06:04:26 -06:00
|
|
|
switch (XGIbios_mode[myindex].xres) {
|
|
|
|
case 512:
|
|
|
|
case 640:
|
|
|
|
case 800:
|
|
|
|
break;
|
|
|
|
case 720:
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->TV_type == TVMODE_NTSC) {
|
2010-09-06 06:04:26 -06:00
|
|
|
if (XGIbios_mode[myindex].yres != 480)
|
|
|
|
return -1;
|
2011-10-11 12:47:19 -06:00
|
|
|
} else if (xgifb_info->TV_type == TVMODE_PAL) {
|
2010-09-06 06:04:26 -06:00
|
|
|
if (XGIbios_mode[myindex].yres != 576)
|
|
|
|
return -1;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
2012-07-06 04:40:36 -06:00
|
|
|
/* LVDS/CHRONTEL does not support 720 */
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->hasVB == HASVB_LVDS_CHRONTEL ||
|
|
|
|
xgifb_info->hasVB == HASVB_CHRONTEL) {
|
2010-09-06 06:04:26 -06:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1024:
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->TV_type == TVMODE_NTSC) {
|
2010-09-06 06:04:26 -06:00
|
|
|
if (XGIbios_mode[myindex].bpp == 32)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -1;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
break;
|
2011-10-11 12:47:37 -06:00
|
|
|
case XGIFB_DISP_CRT:
|
2010-09-06 06:04:26 -06:00
|
|
|
if (XGIbios_mode[myindex].xres > 1280)
|
|
|
|
return -1;
|
|
|
|
break;
|
2011-10-11 12:47:37 -06:00
|
|
|
case XGIFB_DISP_NONE:
|
|
|
|
break;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
2012-09-11 15:44:37 -06:00
|
|
|
|
|
|
|
check_memory:
|
|
|
|
required_mem = XGIbios_mode[myindex].xres * XGIbios_mode[myindex].yres *
|
|
|
|
XGIbios_mode[myindex].bpp / 8;
|
|
|
|
if (required_mem > xgifb_info->video_size)
|
|
|
|
return -1;
|
2010-09-06 06:04:26 -06:00
|
|
|
return myindex;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void XGIfb_search_crt2type(const char *name)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
if (name == NULL)
|
2010-05-19 02:44:14 -06:00
|
|
|
return;
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
while (XGI_crt2type[i].type_no != -1) {
|
2010-05-19 02:44:14 -06:00
|
|
|
if (!strcmp(name, XGI_crt2type[i].name)) {
|
|
|
|
XGIfb_crt2type = XGI_crt2type[i].type_no;
|
|
|
|
XGIfb_tvplug = XGI_crt2type[i].tvplug_no;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2010-09-06 06:04:26 -06:00
|
|
|
if (XGIfb_crt2type < 0)
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_info("Invalid CRT2 type: %s\n", name);
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info,
|
|
|
|
unsigned int rate)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
|
|
|
u16 xres, yres;
|
|
|
|
int i = 0;
|
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
xres = XGIbios_mode[xgifb_info->mode_idx].xres;
|
|
|
|
yres = XGIbios_mode[xgifb_info->mode_idx].yres;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:23 -06:00
|
|
|
xgifb_info->rate_idx = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
while ((XGIfb_vrate[i].idx != 0) && (XGIfb_vrate[i].xres <= xres)) {
|
2011-04-25 22:13:43 -06:00
|
|
|
if ((XGIfb_vrate[i].xres == xres) &&
|
|
|
|
(XGIfb_vrate[i].yres == yres)) {
|
2010-05-19 02:44:14 -06:00
|
|
|
if (XGIfb_vrate[i].refresh == rate) {
|
2011-10-11 12:47:23 -06:00
|
|
|
xgifb_info->rate_idx = XGIfb_vrate[i].idx;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
|
|
|
} else if (XGIfb_vrate[i].refresh > rate) {
|
|
|
|
if ((XGIfb_vrate[i].refresh - rate) <= 3) {
|
2012-07-06 04:40:40 -06:00
|
|
|
pr_debug("Adjusting rate from %d up to %d\n",
|
2012-06-18 05:12:01 -06:00
|
|
|
rate, XGIfb_vrate[i].refresh);
|
2011-10-11 12:47:23 -06:00
|
|
|
xgifb_info->rate_idx =
|
|
|
|
XGIfb_vrate[i].idx;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->refresh_rate =
|
2011-04-25 22:13:43 -06:00
|
|
|
XGIfb_vrate[i].refresh;
|
2010-09-06 06:04:26 -06:00
|
|
|
} else if (((rate - XGIfb_vrate[i - 1].refresh)
|
|
|
|
<= 2) && (XGIfb_vrate[i].idx
|
|
|
|
!= 1)) {
|
2012-07-06 04:40:40 -06:00
|
|
|
pr_debug("Adjusting rate from %d down to %d\n",
|
2012-07-06 04:40:53 -06:00
|
|
|
rate,
|
|
|
|
XGIfb_vrate[i-1].refresh);
|
2011-10-11 12:47:23 -06:00
|
|
|
xgifb_info->rate_idx =
|
|
|
|
XGIfb_vrate[i - 1].idx;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->refresh_rate =
|
2011-04-25 22:13:43 -06:00
|
|
|
XGIfb_vrate[i - 1].refresh;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
} else if ((rate - XGIfb_vrate[i].refresh) <= 2) {
|
2012-07-06 04:40:40 -06:00
|
|
|
pr_debug("Adjusting rate from %d down to %d\n",
|
2012-06-18 05:12:01 -06:00
|
|
|
rate, XGIfb_vrate[i].refresh);
|
2011-10-11 12:47:23 -06:00
|
|
|
xgifb_info->rate_idx = XGIfb_vrate[i].idx;
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2014-09-05 09:09:34 -06:00
|
|
|
if (xgifb_info->rate_idx > 0)
|
2011-10-11 12:47:23 -06:00
|
|
|
return xgifb_info->rate_idx;
|
2014-09-05 09:09:34 -06:00
|
|
|
pr_info("Unsupported rate %d for %dx%d\n",
|
|
|
|
rate, xres, yres);
|
|
|
|
return 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void XGIfb_search_tvstd(const char *name)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
if (name == NULL)
|
2010-05-19 02:44:14 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
while (XGI_tvtype[i].type_no != -1) {
|
|
|
|
if (!strcmp(name, XGI_tvtype[i].name)) {
|
|
|
|
XGIfb_tvmode = XGI_tvtype[i].type_no;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------- FBDev related routines for all series ----------- */
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
static void XGIfb_bpp_to_var(struct xgifb_video_info *xgifb_info,
|
|
|
|
struct fb_var_screeninfo *var)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2010-09-06 06:04:26 -06:00
|
|
|
switch (var->bits_per_pixel) {
|
|
|
|
case 8:
|
|
|
|
var->red.offset = var->green.offset = var->blue.offset = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
var->red.length = var->green.length = var->blue.length = 6;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_cmap_len = 256;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case 16:
|
2010-05-19 02:44:14 -06:00
|
|
|
var->red.offset = 11;
|
|
|
|
var->red.length = 5;
|
|
|
|
var->green.offset = 5;
|
|
|
|
var->green.length = 6;
|
|
|
|
var->blue.offset = 0;
|
|
|
|
var->blue.length = 5;
|
|
|
|
var->transp.offset = 0;
|
|
|
|
var->transp.length = 0;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_cmap_len = 16;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case 32:
|
2010-05-19 02:44:14 -06:00
|
|
|
var->red.offset = 16;
|
|
|
|
var->red.length = 8;
|
|
|
|
var->green.offset = 8;
|
|
|
|
var->green.length = 8;
|
|
|
|
var->blue.offset = 0;
|
|
|
|
var->blue.length = 8;
|
|
|
|
var->transp.offset = 24;
|
|
|
|
var->transp.length = 8;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_cmap_len = 16;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-18 13:14:05 -06:00
|
|
|
/* --------------------- SetMode routines ------------------------- */
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
static void XGIfb_pre_setmode(struct xgifb_video_info *xgifb_info)
|
2011-04-18 13:14:05 -06:00
|
|
|
{
|
|
|
|
u8 cr30 = 0, cr31 = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-18 13:14:05 -06:00
|
|
|
cr31 = xgifb_reg_get(XGICR, 0x31);
|
|
|
|
cr31 &= ~0x60;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:37 -06:00
|
|
|
switch (xgifb_info->display2) {
|
|
|
|
case XGIFB_DISP_CRT:
|
2012-01-15 11:22:12 -07:00
|
|
|
cr30 = (SIS_VB_OUTPUT_CRT2 | SIS_SIMULTANEOUS_VIEW_ENABLE);
|
|
|
|
cr31 |= SIS_DRIVER_MODE;
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
2011-10-11 12:47:37 -06:00
|
|
|
case XGIFB_DISP_LCD:
|
2012-01-15 11:22:12 -07:00
|
|
|
cr30 = (SIS_VB_OUTPUT_LCD | SIS_SIMULTANEOUS_VIEW_ENABLE);
|
|
|
|
cr31 |= SIS_DRIVER_MODE;
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
2011-10-11 12:47:37 -06:00
|
|
|
case XGIFB_DISP_TV:
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->TV_type == TVMODE_HIVISION)
|
2012-01-15 11:22:12 -07:00
|
|
|
cr30 = (SIS_VB_OUTPUT_HIVISION
|
|
|
|
| SIS_SIMULTANEOUS_VIEW_ENABLE);
|
2011-10-11 12:47:19 -06:00
|
|
|
else if (xgifb_info->TV_plug == TVPLUG_SVIDEO)
|
2012-01-15 11:22:12 -07:00
|
|
|
cr30 = (SIS_VB_OUTPUT_SVIDEO
|
|
|
|
| SIS_SIMULTANEOUS_VIEW_ENABLE);
|
2011-10-11 12:47:19 -06:00
|
|
|
else if (xgifb_info->TV_plug == TVPLUG_COMPOSITE)
|
2012-01-15 11:22:12 -07:00
|
|
|
cr30 = (SIS_VB_OUTPUT_COMPOSITE
|
|
|
|
| SIS_SIMULTANEOUS_VIEW_ENABLE);
|
2011-10-11 12:47:19 -06:00
|
|
|
else if (xgifb_info->TV_plug == TVPLUG_SCART)
|
2012-01-15 11:22:12 -07:00
|
|
|
cr30 = (SIS_VB_OUTPUT_SCART
|
|
|
|
| SIS_SIMULTANEOUS_VIEW_ENABLE);
|
|
|
|
cr31 |= SIS_DRIVER_MODE;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (XGIfb_tvmode == 1 || xgifb_info->TV_type == TVMODE_PAL)
|
2011-04-18 13:14:05 -06:00
|
|
|
cr31 |= 0x01;
|
|
|
|
else
|
|
|
|
cr31 &= ~0x01;
|
|
|
|
break;
|
|
|
|
default: /* disable CRT2 */
|
|
|
|
cr30 = 0x00;
|
2012-01-15 11:22:12 -07:00
|
|
|
cr31 |= (SIS_DRIVER_MODE | SIS_VB_OUTPUT_DISABLE);
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2011-04-18 13:14:05 -06:00
|
|
|
xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR30, cr30);
|
|
|
|
xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR31, cr31);
|
2011-10-11 12:47:23 -06:00
|
|
|
xgifb_reg_set(XGICR, IND_XGI_SCRATCH_REG_CR33,
|
|
|
|
(xgifb_info->rate_idx & 0x0F));
|
2011-04-18 13:14:05 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
|
2011-04-18 13:14:05 -06:00
|
|
|
{
|
|
|
|
u8 reg;
|
|
|
|
unsigned char doit = 1;
|
2012-07-06 04:40:36 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->video_bpp == 8) {
|
2012-07-06 04:40:36 -06:00
|
|
|
/*
|
|
|
|
* We can't switch off CRT1 on LVDS/Chrontel
|
|
|
|
* in 8bpp Modes
|
|
|
|
*/
|
2011-10-11 12:47:19 -06:00
|
|
|
if ((xgifb_info->hasVB == HASVB_LVDS) ||
|
|
|
|
(xgifb_info->hasVB == HASVB_LVDS_CHRONTEL)) {
|
2011-04-18 13:14:05 -06:00
|
|
|
doit = 0;
|
|
|
|
}
|
2012-07-06 04:40:36 -06:00
|
|
|
/*
|
|
|
|
* We can't switch off CRT1 on 301B-DH
|
|
|
|
* in 8bpp Modes if using LCD
|
|
|
|
*/
|
2011-10-11 12:47:37 -06:00
|
|
|
if (xgifb_info->display2 == XGIFB_DISP_LCD)
|
2011-04-18 13:14:05 -06:00
|
|
|
doit = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
/* We can't switch off CRT1 if bridge is in slave mode */
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->hasVB != HASVB_NONE) {
|
2011-04-18 13:14:05 -06:00
|
|
|
reg = xgifb_reg_get(XGIPART1, 0x00);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-18 13:14:05 -06:00
|
|
|
if ((reg & 0x50) == 0x10)
|
|
|
|
doit = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-18 13:14:05 -06:00
|
|
|
} else {
|
|
|
|
XGIfb_crt1off = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2011-04-18 13:14:05 -06:00
|
|
|
reg = xgifb_reg_get(XGICR, 0x17);
|
|
|
|
if ((XGIfb_crt1off) && (doit))
|
|
|
|
reg &= ~0x80;
|
2010-05-19 02:44:14 -06:00
|
|
|
else
|
2011-04-18 13:14:05 -06:00
|
|
|
reg |= 0x80;
|
|
|
|
xgifb_reg_set(XGICR, 0x17, reg);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-01-15 11:22:12 -07:00
|
|
|
xgifb_reg_and(XGISR, IND_SIS_RAMDAC_CONTROL, ~0x04);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:37 -06:00
|
|
|
if (xgifb_info->display2 == XGIFB_DISP_TV &&
|
|
|
|
xgifb_info->hasVB == HASVB_301) {
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-18 13:14:05 -06:00
|
|
|
reg = xgifb_reg_get(XGIPART4, 0x01);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-18 13:14:05 -06:00
|
|
|
if (reg < 0xB0) { /* Set filter for XGI301 */
|
2011-10-11 12:47:28 -06:00
|
|
|
int filter_tb;
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
switch (xgifb_info->video_width) {
|
2011-04-18 13:14:05 -06:00
|
|
|
case 320:
|
2011-10-11 12:47:19 -06:00
|
|
|
filter_tb = (xgifb_info->TV_type ==
|
2011-04-25 22:13:43 -06:00
|
|
|
TVMODE_NTSC) ? 4 : 12;
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
|
|
|
case 640:
|
2011-10-11 12:47:19 -06:00
|
|
|
filter_tb = (xgifb_info->TV_type ==
|
2011-04-25 22:13:43 -06:00
|
|
|
TVMODE_NTSC) ? 5 : 13;
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
|
|
|
case 720:
|
2011-10-11 12:47:19 -06:00
|
|
|
filter_tb = (xgifb_info->TV_type ==
|
2011-04-25 22:13:43 -06:00
|
|
|
TVMODE_NTSC) ? 6 : 14;
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
|
|
|
case 800:
|
2011-10-11 12:47:19 -06:00
|
|
|
filter_tb = (xgifb_info->TV_type ==
|
2011-04-25 22:13:43 -06:00
|
|
|
TVMODE_NTSC) ? 7 : 15;
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
|
|
|
default:
|
2011-10-11 12:47:28 -06:00
|
|
|
filter_tb = 0;
|
2011-04-18 13:14:05 -06:00
|
|
|
filter = -1;
|
|
|
|
break;
|
|
|
|
}
|
2011-10-11 12:47:25 -06:00
|
|
|
xgifb_reg_or(XGIPART1,
|
2012-01-15 11:22:12 -07:00
|
|
|
SIS_CRT2_WENABLE_315,
|
2011-10-11 12:47:25 -06:00
|
|
|
0x01);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->TV_type == TVMODE_NTSC) {
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-18 13:14:05 -06:00
|
|
|
xgifb_reg_and(XGIPART2, 0x3a, 0x1f);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->TV_plug == TVPLUG_SVIDEO) {
|
2011-04-18 13:14:05 -06:00
|
|
|
|
|
|
|
xgifb_reg_and(XGIPART2, 0x30, 0xdf);
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
} else if (xgifb_info->TV_plug
|
2011-04-18 13:14:05 -06:00
|
|
|
== TVPLUG_COMPOSITE) {
|
|
|
|
|
|
|
|
xgifb_reg_or(XGIPART2, 0x30, 0x20);
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
switch (xgifb_info->video_width) {
|
2011-04-18 13:14:05 -06:00
|
|
|
case 640:
|
2011-04-25 22:13:43 -06:00
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x35,
|
|
|
|
0xEB);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x36,
|
|
|
|
0x04);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x37,
|
|
|
|
0x25);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x38,
|
|
|
|
0x18);
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
|
|
|
case 720:
|
2011-04-25 22:13:43 -06:00
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x35,
|
|
|
|
0xEE);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x36,
|
|
|
|
0x0C);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x37,
|
|
|
|
0x22);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x38,
|
|
|
|
0x08);
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
|
|
|
case 800:
|
2011-04-25 22:13:43 -06:00
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x35,
|
|
|
|
0xEB);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x36,
|
|
|
|
0x15);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x37,
|
|
|
|
0x25);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x38,
|
|
|
|
0xF6);
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
} else if (xgifb_info->TV_type == TVMODE_PAL) {
|
2011-04-18 13:14:05 -06:00
|
|
|
|
|
|
|
xgifb_reg_and(XGIPART2, 0x3A, 0x1F);
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->TV_plug == TVPLUG_SVIDEO) {
|
2011-04-18 13:14:05 -06:00
|
|
|
|
|
|
|
xgifb_reg_and(XGIPART2, 0x30, 0xDF);
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
} else if (xgifb_info->TV_plug
|
2011-04-18 13:14:05 -06:00
|
|
|
== TVPLUG_COMPOSITE) {
|
|
|
|
|
|
|
|
xgifb_reg_or(XGIPART2, 0x30, 0x20);
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
switch (xgifb_info->video_width) {
|
2011-04-18 13:14:05 -06:00
|
|
|
case 640:
|
2011-04-25 22:13:43 -06:00
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x35,
|
|
|
|
0xF1);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x36,
|
|
|
|
0xF7);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x37,
|
|
|
|
0x1F);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x38,
|
|
|
|
0x32);
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
|
|
|
case 720:
|
2011-04-25 22:13:43 -06:00
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x35,
|
|
|
|
0xF3);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x36,
|
|
|
|
0x00);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x37,
|
|
|
|
0x1D);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x38,
|
|
|
|
0x20);
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
|
|
|
case 800:
|
2011-04-25 22:13:43 -06:00
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x35,
|
|
|
|
0xFC);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x36,
|
|
|
|
0xFB);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x37,
|
|
|
|
0x14);
|
|
|
|
xgifb_reg_set(XGIPART2,
|
|
|
|
0x38,
|
|
|
|
0x2A);
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((filter >= 0) && (filter <= 7)) {
|
2012-08-02 10:05:52 -06:00
|
|
|
pr_debug("FilterTable[%d]-%d: %*ph\n",
|
2012-06-18 05:12:01 -06:00
|
|
|
filter_tb, filter,
|
2012-08-02 10:05:52 -06:00
|
|
|
4, XGI_TV_filter[filter_tb].
|
|
|
|
filter[filter]);
|
2011-04-18 13:14:05 -06:00
|
|
|
xgifb_reg_set(
|
2011-04-25 22:13:43 -06:00
|
|
|
XGIPART2,
|
|
|
|
0x35,
|
|
|
|
(XGI_TV_filter[filter_tb].
|
|
|
|
filter[filter][0]));
|
2011-04-18 13:14:05 -06:00
|
|
|
xgifb_reg_set(
|
2011-04-25 22:13:43 -06:00
|
|
|
XGIPART2,
|
|
|
|
0x36,
|
|
|
|
(XGI_TV_filter[filter_tb].
|
|
|
|
filter[filter][1]));
|
2011-04-18 13:14:05 -06:00
|
|
|
xgifb_reg_set(
|
2011-04-25 22:13:43 -06:00
|
|
|
XGIPART2,
|
|
|
|
0x37,
|
|
|
|
(XGI_TV_filter[filter_tb].
|
|
|
|
filter[filter][2]));
|
2011-04-18 13:14:05 -06:00
|
|
|
xgifb_reg_set(
|
2011-04-25 22:13:43 -06:00
|
|
|
XGIPART2,
|
|
|
|
0x38,
|
|
|
|
(XGI_TV_filter[filter_tb].
|
|
|
|
filter[filter][3]));
|
2011-04-18 13:14:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
|
|
|
|
struct fb_info *info)
|
|
|
|
{
|
2011-10-11 12:47:19 -06:00
|
|
|
struct xgifb_video_info *xgifb_info = info->par;
|
|
|
|
struct xgi_hw_device_info *hw_info = &xgifb_info->hw_info;
|
2011-04-18 13:14:05 -06:00
|
|
|
unsigned int htotal = var->left_margin + var->xres + var->right_margin
|
|
|
|
+ var->hsync_len;
|
|
|
|
unsigned int vtotal = var->upper_margin + var->yres + var->lower_margin
|
|
|
|
+ var->vsync_len;
|
2015-02-01 08:01:33 -07:00
|
|
|
#if defined(__BIG_ENDIAN)
|
2012-03-19 11:50:11 -06:00
|
|
|
u8 cr_data;
|
2011-04-18 13:14:05 -06:00
|
|
|
#endif
|
|
|
|
unsigned int drate = 0, hrate = 0;
|
|
|
|
int found_mode = 0;
|
|
|
|
int old_mode;
|
|
|
|
|
|
|
|
info->var.xres_virtual = var->xres_virtual;
|
|
|
|
info->var.yres_virtual = var->yres_virtual;
|
|
|
|
info->var.bits_per_pixel = var->bits_per_pixel;
|
|
|
|
|
|
|
|
if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED)
|
|
|
|
vtotal <<= 1;
|
|
|
|
else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
|
|
|
|
vtotal <<= 2;
|
|
|
|
|
|
|
|
if (!htotal || !vtotal) {
|
2012-07-06 04:40:40 -06:00
|
|
|
pr_debug("Invalid 'var' information\n");
|
2011-04-18 13:14:05 -06:00
|
|
|
return -EINVAL;
|
2012-01-22 17:48:53 -07:00
|
|
|
} pr_debug("var->pixclock=%d, htotal=%d, vtotal=%d\n",
|
2011-04-18 13:14:05 -06:00
|
|
|
var->pixclock, htotal, vtotal);
|
|
|
|
|
2014-12-31 04:27:46 -07:00
|
|
|
if (var->pixclock) {
|
2011-04-18 13:14:05 -06:00
|
|
|
drate = 1000000000 / var->pixclock;
|
|
|
|
hrate = (drate * 1000) / htotal;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->refresh_rate = (unsigned int) (hrate * 2
|
2011-04-18 13:14:05 -06:00
|
|
|
/ vtotal);
|
|
|
|
} else {
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->refresh_rate = 60;
|
2011-04-18 13:14:05 -06:00
|
|
|
}
|
|
|
|
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_debug("Change mode to %dx%dx%d-%dHz\n",
|
2011-04-25 22:13:43 -06:00
|
|
|
var->xres,
|
|
|
|
var->yres,
|
|
|
|
var->bits_per_pixel,
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->refresh_rate);
|
2011-04-18 13:14:05 -06:00
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
old_mode = xgifb_info->mode_idx;
|
|
|
|
xgifb_info->mode_idx = 0;
|
2011-04-18 13:14:05 -06:00
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
while ((XGIbios_mode[xgifb_info->mode_idx].mode_no != 0) &&
|
|
|
|
(XGIbios_mode[xgifb_info->mode_idx].xres <= var->xres)) {
|
|
|
|
if ((XGIbios_mode[xgifb_info->mode_idx].xres == var->xres) &&
|
|
|
|
(XGIbios_mode[xgifb_info->mode_idx].yres == var->yres) &&
|
|
|
|
(XGIbios_mode[xgifb_info->mode_idx].bpp
|
2011-04-18 13:14:05 -06:00
|
|
|
== var->bits_per_pixel)) {
|
|
|
|
found_mode = 1;
|
|
|
|
break;
|
|
|
|
}
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->mode_idx++;
|
2011-04-18 13:14:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (found_mode)
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->mode_idx = XGIfb_validate_mode(xgifb_info,
|
|
|
|
xgifb_info->mode_idx);
|
2011-04-18 13:14:05 -06:00
|
|
|
else
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->mode_idx = -1;
|
2011-04-18 13:14:05 -06:00
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
if (xgifb_info->mode_idx < 0) {
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_err("Mode %dx%dx%d not supported\n",
|
2011-04-25 22:13:43 -06:00
|
|
|
var->xres, var->yres, var->bits_per_pixel);
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->mode_idx = old_mode;
|
2011-04-18 13:14:05 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (XGIfb_search_refresh_rate(xgifb_info,
|
|
|
|
xgifb_info->refresh_rate) == 0) {
|
2012-04-06 16:13:54 -06:00
|
|
|
xgifb_info->rate_idx = 1;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->refresh_rate = 60;
|
2011-04-18 13:14:05 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isactive) {
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
XGIfb_pre_setmode(xgifb_info);
|
2011-12-05 15:10:45 -07:00
|
|
|
if (XGISetModeNew(xgifb_info, hw_info,
|
2011-10-11 12:47:22 -06:00
|
|
|
XGIbios_mode[xgifb_info->mode_idx].mode_no)
|
|
|
|
== 0) {
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_err("Setting mode[0x%x] failed\n",
|
2011-10-11 12:47:22 -06:00
|
|
|
XGIbios_mode[xgifb_info->mode_idx].mode_no);
|
2011-04-18 13:14:05 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2015-03-03 22:35:48 -07:00
|
|
|
info->fix.line_length = (info->var.xres_virtual
|
|
|
|
* info->var.bits_per_pixel) >> 6;
|
2011-04-18 13:14:05 -06:00
|
|
|
|
2012-01-15 11:22:12 -07:00
|
|
|
xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD);
|
2011-04-18 13:14:05 -06:00
|
|
|
|
|
|
|
xgifb_reg_set(XGICR, 0x13, (info->fix.line_length & 0x00ff));
|
2011-04-25 22:13:43 -06:00
|
|
|
xgifb_reg_set(XGISR,
|
|
|
|
0x0E,
|
|
|
|
(info->fix.line_length & 0xff00) >> 8);
|
2011-04-18 13:14:05 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
XGIfb_post_setmode(xgifb_info);
|
2011-04-18 13:14:05 -06:00
|
|
|
|
2012-07-06 04:40:40 -06:00
|
|
|
pr_debug("Set new mode: %dx%dx%d-%d\n",
|
2012-06-18 05:12:01 -06:00
|
|
|
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);
|
2011-10-11 12:47:19 -06:00
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->video_bpp = XGIbios_mode[xgifb_info->mode_idx].bpp;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_vwidth = info->var.xres_virtual;
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->video_width =
|
|
|
|
XGIbios_mode[xgifb_info->mode_idx].xres;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_vheight = info->var.yres_virtual;
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->video_height =
|
|
|
|
XGIbios_mode[xgifb_info->mode_idx].yres;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->org_x = xgifb_info->org_y = 0;
|
|
|
|
xgifb_info->video_linelength = info->var.xres_virtual
|
|
|
|
* (xgifb_info->video_bpp >> 3);
|
|
|
|
switch (xgifb_info->video_bpp) {
|
2011-04-18 13:14:05 -06:00
|
|
|
case 8:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->DstColor = 0x0000;
|
|
|
|
xgifb_info->XGI310_AccelDepth = 0x00000000;
|
|
|
|
xgifb_info->video_cmap_len = 256;
|
2015-02-01 08:01:33 -07:00
|
|
|
#if defined(__BIG_ENDIAN)
|
2011-04-18 13:14:05 -06:00
|
|
|
cr_data = xgifb_reg_get(XGICR, 0x4D);
|
|
|
|
xgifb_reg_set(XGICR, 0x4D, (cr_data & 0xE0));
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 16:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->DstColor = 0x8000;
|
|
|
|
xgifb_info->XGI310_AccelDepth = 0x00010000;
|
2015-02-01 08:01:33 -07:00
|
|
|
#if defined(__BIG_ENDIAN)
|
2011-04-18 13:13:58 -06:00
|
|
|
cr_data = xgifb_reg_get(XGICR, 0x4D);
|
2011-04-18 13:13:59 -06:00
|
|
|
xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x0B));
|
2010-05-19 02:44:14 -06:00
|
|
|
#endif
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_cmap_len = 16;
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
case 32:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->DstColor = 0xC000;
|
|
|
|
xgifb_info->XGI310_AccelDepth = 0x00020000;
|
|
|
|
xgifb_info->video_cmap_len = 16;
|
2015-02-01 08:01:33 -07:00
|
|
|
#if defined(__BIG_ENDIAN)
|
2011-04-18 13:13:58 -06:00
|
|
|
cr_data = xgifb_reg_get(XGICR, 0x4D);
|
2011-04-18 13:13:59 -06:00
|
|
|
xgifb_reg_set(XGICR, 0x4D, ((cr_data & 0xE0) | 0x15));
|
2010-05-19 02:44:14 -06:00
|
|
|
#endif
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
default:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_cmap_len = 16;
|
2012-07-06 04:40:40 -06:00
|
|
|
pr_err("Unsupported depth %d\n",
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_bpp);
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
2011-10-11 12:47:19 -06:00
|
|
|
XGIfb_bpp_to_var(xgifb_info, var); /*update ARGB info*/
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
dumpVGAReg();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-25 03:34:52 -06:00
|
|
|
static int XGIfb_pan_var(struct fb_var_screeninfo *var, struct fb_info *info)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2011-10-30 16:30:01 -06:00
|
|
|
struct xgifb_video_info *xgifb_info = info->par;
|
2010-05-19 02:44:14 -06:00
|
|
|
unsigned int base;
|
|
|
|
|
2011-05-25 03:34:52 -06:00
|
|
|
base = var->yoffset * info->var.xres_virtual + var->xoffset;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
/* calculate base bpp dep. */
|
2011-05-25 03:34:52 -06:00
|
|
|
switch (info->var.bits_per_pixel) {
|
2010-09-06 06:04:26 -06:00
|
|
|
case 16:
|
|
|
|
base >>= 1;
|
|
|
|
break;
|
2010-05-19 02:44:14 -06:00
|
|
|
case 32:
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
2010-05-19 02:44:14 -06:00
|
|
|
case 8:
|
2010-09-06 06:04:26 -06:00
|
|
|
default:
|
|
|
|
base >>= 2;
|
|
|
|
break;
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-01-15 11:22:12 -07:00
|
|
|
xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-18 13:13:59 -06:00
|
|
|
xgifb_reg_set(XGICR, 0x0D, base & 0xFF);
|
|
|
|
xgifb_reg_set(XGICR, 0x0C, (base >> 8) & 0xFF);
|
|
|
|
xgifb_reg_set(XGISR, 0x0D, (base >> 16) & 0xFF);
|
|
|
|
xgifb_reg_set(XGISR, 0x37, (base >> 24) & 0x03);
|
2011-04-18 13:14:02 -06:00
|
|
|
xgifb_reg_and_or(XGISR, 0x37, 0xDF, (base >> 21) & 0x04);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:37 -06:00
|
|
|
if (xgifb_info->display2 != XGIFB_DISP_NONE) {
|
2012-01-15 11:22:12 -07:00
|
|
|
xgifb_reg_or(XGIPART1, SIS_CRT2_WENABLE_315, 0x01);
|
2011-04-18 13:13:59 -06:00
|
|
|
xgifb_reg_set(XGIPART1, 0x06, (base & 0xFF));
|
|
|
|
xgifb_reg_set(XGIPART1, 0x05, ((base >> 8) & 0xFF));
|
|
|
|
xgifb_reg_set(XGIPART1, 0x04, ((base >> 16) & 0xFF));
|
2011-04-25 22:13:43 -06:00
|
|
|
xgifb_reg_and_or(XGIPART1,
|
|
|
|
0x02,
|
|
|
|
0x7F,
|
|
|
|
((base >> 24) & 0x01) << 7);
|
2010-09-06 06:04:26 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int XGIfb_open(struct fb_info *info, int user)
|
|
|
|
{
|
2010-09-06 06:04:26 -06:00
|
|
|
return 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static int XGIfb_release(struct fb_info *info, int user)
|
|
|
|
{
|
2010-09-06 06:04:26 -06:00
|
|
|
return 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2013-02-03 14:54:35 -07:00
|
|
|
/* similar to sisfb_get_cmap_len */
|
2010-05-19 02:44:14 -06:00
|
|
|
static int XGIfb_get_cmap_len(const struct fb_var_screeninfo *var)
|
|
|
|
{
|
2013-02-03 14:54:35 -07:00
|
|
|
return (var->bits_per_pixel == 8) ? 256 : 16;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
static int XGIfb_setcolreg(unsigned regno, unsigned red, unsigned green,
|
|
|
|
unsigned blue, unsigned transp, struct fb_info *info)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2011-10-11 12:47:19 -06:00
|
|
|
struct xgifb_video_info *xgifb_info = info->par;
|
|
|
|
|
2010-05-19 02:44:14 -06:00
|
|
|
if (regno >= XGIfb_get_cmap_len(&info->var))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
switch (info->var.bits_per_pixel) {
|
|
|
|
case 8:
|
2011-04-18 13:13:57 -06:00
|
|
|
outb(regno, XGIDACA);
|
|
|
|
outb((red >> 10), XGIDACD);
|
|
|
|
outb((green >> 10), XGIDACD);
|
|
|
|
outb((blue >> 10), XGIDACD);
|
2011-10-11 12:47:37 -06:00
|
|
|
if (xgifb_info->display2 != XGIFB_DISP_NONE) {
|
2011-04-18 13:13:57 -06:00
|
|
|
outb(regno, XGIDAC2A);
|
|
|
|
outb((red >> 8), XGIDAC2D);
|
|
|
|
outb((green >> 8), XGIDAC2D);
|
|
|
|
outb((blue >> 8), XGIDAC2D);
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16:
|
2010-09-06 06:04:26 -06:00
|
|
|
((u32 *) (info->pseudo_palette))[regno] = ((red & 0xf800))
|
|
|
|
| ((green & 0xfc00) >> 5) | ((blue & 0xf800)
|
|
|
|
>> 11);
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
red >>= 8;
|
|
|
|
green >>= 8;
|
|
|
|
blue >>= 8;
|
2010-09-06 06:04:26 -06:00
|
|
|
((u32 *) (info->pseudo_palette))[regno] = (red << 16) | (green
|
|
|
|
<< 8) | (blue);
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-18 13:14:05 -06:00
|
|
|
/* ----------- FBDev related routines for all series ---------- */
|
|
|
|
|
|
|
|
static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con,
|
|
|
|
struct fb_info *info)
|
|
|
|
{
|
2011-10-11 12:47:19 -06:00
|
|
|
struct xgifb_video_info *xgifb_info = info->par;
|
|
|
|
|
2011-04-18 13:14:05 -06:00
|
|
|
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
|
|
|
|
|
2012-06-13 16:21:39 -06:00
|
|
|
strncpy(fix->id, "XGI", sizeof(fix->id) - 1);
|
|
|
|
|
2012-06-13 16:21:40 -06:00
|
|
|
/* if register_framebuffer has been called, we must lock */
|
|
|
|
if (atomic_read(&info->count))
|
|
|
|
mutex_lock(&info->mm_lock);
|
2011-04-18 13:14:05 -06:00
|
|
|
|
2012-06-13 16:21:40 -06:00
|
|
|
fix->smem_start = xgifb_info->video_base;
|
2011-10-11 12:47:19 -06:00
|
|
|
fix->smem_len = xgifb_info->video_size;
|
2011-04-18 13:14:05 -06:00
|
|
|
|
2012-06-13 16:21:40 -06:00
|
|
|
/* if register_framebuffer has been called, we can unlock */
|
|
|
|
if (atomic_read(&info->count))
|
|
|
|
mutex_unlock(&info->mm_lock);
|
|
|
|
|
2011-08-19 13:40:27 -06:00
|
|
|
fix->type = FB_TYPE_PACKED_PIXELS;
|
2011-04-18 13:14:05 -06:00
|
|
|
fix->type_aux = 0;
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->video_bpp == 8)
|
2011-04-18 13:14:05 -06:00
|
|
|
fix->visual = FB_VISUAL_PSEUDOCOLOR;
|
|
|
|
else
|
|
|
|
fix->visual = FB_VISUAL_DIRECTCOLOR;
|
|
|
|
fix->xpanstep = 0;
|
|
|
|
if (XGIfb_ypan)
|
|
|
|
fix->ypanstep = 1;
|
|
|
|
fix->ywrapstep = 0;
|
2011-10-11 12:47:19 -06:00
|
|
|
fix->line_length = xgifb_info->video_linelength;
|
|
|
|
fix->mmio_start = xgifb_info->mmio_base;
|
|
|
|
fix->mmio_len = xgifb_info->mmio_size;
|
2012-01-15 11:22:12 -07:00
|
|
|
fix->accel = FB_ACCEL_SIS_XABRE;
|
2011-04-18 13:14:05 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-19 02:44:14 -06:00
|
|
|
static int XGIfb_set_par(struct fb_info *info)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
err = XGIfb_do_set_var(&info->var, 1, info);
|
|
|
|
if (err)
|
2010-05-19 02:44:14 -06:00
|
|
|
return err;
|
|
|
|
XGIfb_get_fix(&info->fix, -1, info);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2011-10-11 12:47:19 -06:00
|
|
|
struct xgifb_video_info *xgifb_info = info->par;
|
2010-09-06 06:04:26 -06:00
|
|
|
unsigned int htotal = var->left_margin + var->xres + var->right_margin
|
|
|
|
+ var->hsync_len;
|
2010-05-19 02:44:14 -06:00
|
|
|
unsigned int vtotal = 0;
|
|
|
|
unsigned int drate = 0, hrate = 0;
|
|
|
|
int found_mode = 0;
|
|
|
|
int refresh_rate, search_idx;
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) {
|
|
|
|
vtotal = var->upper_margin + var->yres + var->lower_margin
|
|
|
|
+ var->vsync_len;
|
2010-05-19 02:44:14 -06:00
|
|
|
vtotal <<= 1;
|
2010-09-06 06:04:26 -06:00
|
|
|
} else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
|
|
|
|
vtotal = var->upper_margin + var->yres + var->lower_margin
|
|
|
|
+ var->vsync_len;
|
2010-05-19 02:44:14 -06:00
|
|
|
vtotal <<= 2;
|
2010-09-06 06:04:26 -06:00
|
|
|
} else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
|
|
|
|
vtotal = var->upper_margin + (var->yres / 2)
|
|
|
|
+ var->lower_margin + var->vsync_len;
|
|
|
|
} else
|
|
|
|
vtotal = var->upper_margin + var->yres + var->lower_margin
|
|
|
|
+ var->vsync_len;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-06-18 05:12:03 -06:00
|
|
|
if (!(htotal) || !(vtotal)) {
|
2012-07-06 04:40:40 -06:00
|
|
|
pr_debug("No valid timing data\n");
|
2012-06-18 05:12:03 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
if (var->pixclock && htotal && vtotal) {
|
|
|
|
drate = 1000000000 / var->pixclock;
|
|
|
|
hrate = (drate * 1000) / htotal;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->refresh_rate =
|
2011-04-25 22:13:43 -06:00
|
|
|
(unsigned int) (hrate * 2 / vtotal);
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_debug(
|
2010-09-06 06:04:26 -06:00
|
|
|
"%s: pixclock = %d ,htotal=%d, vtotal=%d\n"
|
|
|
|
"%s: drate=%d, hrate=%d, refresh_rate=%d\n",
|
|
|
|
__func__, var->pixclock, htotal, vtotal,
|
2011-10-11 12:47:19 -06:00
|
|
|
__func__, drate, hrate, xgifb_info->refresh_rate);
|
2010-09-06 06:04:26 -06:00
|
|
|
} else {
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->refresh_rate = 60;
|
2010-09-06 06:04:26 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
/* Calculation wrong for 1024x600 - force it to 60Hz */
|
2010-09-06 06:04:26 -06:00
|
|
|
if ((var->xres == 1024) && (var->yres == 600))
|
|
|
|
refresh_rate = 60;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
search_idx = 0;
|
2010-09-06 06:04:26 -06:00
|
|
|
while ((XGIbios_mode[search_idx].mode_no != 0) &&
|
|
|
|
(XGIbios_mode[search_idx].xres <= var->xres)) {
|
|
|
|
if ((XGIbios_mode[search_idx].xres == var->xres) &&
|
|
|
|
(XGIbios_mode[search_idx].yres == var->yres) &&
|
|
|
|
(XGIbios_mode[search_idx].bpp == var->bits_per_pixel)) {
|
2011-10-11 12:47:19 -06:00
|
|
|
if (XGIfb_validate_mode(xgifb_info, search_idx) > 0) {
|
2010-09-06 06:04:26 -06:00
|
|
|
found_mode = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
search_idx++;
|
|
|
|
}
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
if (!found_mode) {
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_err("%dx%dx%d is no valid mode\n",
|
2010-05-19 02:44:14 -06:00
|
|
|
var->xres, var->yres, var->bits_per_pixel);
|
2010-09-06 06:04:26 -06:00
|
|
|
search_idx = 0;
|
|
|
|
while (XGIbios_mode[search_idx].mode_no != 0) {
|
|
|
|
if ((var->xres <= XGIbios_mode[search_idx].xres) &&
|
2011-04-25 22:13:43 -06:00
|
|
|
(var->yres <= XGIbios_mode[search_idx].yres) &&
|
|
|
|
(var->bits_per_pixel ==
|
|
|
|
XGIbios_mode[search_idx].bpp)) {
|
2011-10-11 12:47:19 -06:00
|
|
|
if (XGIfb_validate_mode(xgifb_info,
|
|
|
|
search_idx) > 0) {
|
2010-09-06 06:04:26 -06:00
|
|
|
found_mode = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
search_idx++;
|
|
|
|
}
|
|
|
|
if (found_mode) {
|
2010-05-19 02:44:14 -06:00
|
|
|
var->xres = XGIbios_mode[search_idx].xres;
|
2010-09-06 06:04:26 -06:00
|
|
|
var->yres = XGIbios_mode[search_idx].yres;
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_debug("Adapted to mode %dx%dx%d\n",
|
2010-09-06 06:04:26 -06:00
|
|
|
var->xres, var->yres, var->bits_per_pixel);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
} else {
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_err("Failed to find similar mode to %dx%dx%d\n",
|
2010-05-19 02:44:14 -06:00
|
|
|
var->xres, var->yres, var->bits_per_pixel);
|
2010-09-06 06:04:26 -06:00
|
|
|
return -EINVAL;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Adapt RGB settings */
|
2011-10-11 12:47:19 -06:00
|
|
|
XGIfb_bpp_to_var(xgifb_info, var);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
if (!XGIfb_ypan) {
|
|
|
|
if (var->xres != var->xres_virtual)
|
|
|
|
var->xres_virtual = var->xres;
|
|
|
|
if (var->yres != var->yres_virtual)
|
2010-05-19 02:44:14 -06:00
|
|
|
var->yres_virtual = var->yres;
|
2012-07-06 04:40:36 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
/* Truncate offsets to maximum if too high */
|
|
|
|
if (var->xoffset > var->xres_virtual - var->xres)
|
|
|
|
var->xoffset = var->xres_virtual - var->xres - 1;
|
|
|
|
|
|
|
|
if (var->yoffset > var->yres_virtual - var->yres)
|
|
|
|
var->yoffset = var->yres_virtual - var->yres - 1;
|
|
|
|
|
|
|
|
/* Set everything else to 0 */
|
|
|
|
var->red.msb_right =
|
2010-09-06 06:04:26 -06:00
|
|
|
var->green.msb_right =
|
|
|
|
var->blue.msb_right =
|
|
|
|
var->transp.offset = var->transp.length = var->transp.msb_right = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
static int XGIfb_pan_display(struct fb_var_screeninfo *var,
|
|
|
|
struct fb_info *info)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
2011-05-25 03:34:52 -06:00
|
|
|
if (var->xoffset > (info->var.xres_virtual - info->var.xres))
|
2010-05-19 02:44:14 -06:00
|
|
|
return -EINVAL;
|
2011-05-25 03:34:52 -06:00
|
|
|
if (var->yoffset > (info->var.yres_virtual - info->var.yres))
|
2010-05-19 02:44:14 -06:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (var->vmode & FB_VMODE_YWRAP) {
|
2013-02-03 14:54:31 -07:00
|
|
|
if (var->yoffset >= info->var.yres_virtual || var->xoffset)
|
2010-09-06 06:04:26 -06:00
|
|
|
return -EINVAL;
|
2012-09-10 15:15:27 -06:00
|
|
|
} else if (var->xoffset + info->var.xres > info->var.xres_virtual
|
2010-09-06 06:04:26 -06:00
|
|
|
|| var->yoffset + info->var.yres
|
2012-09-10 15:15:27 -06:00
|
|
|
> info->var.yres_virtual) {
|
|
|
|
return -EINVAL;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
2011-05-25 03:34:52 -06:00
|
|
|
err = XGIfb_pan_var(var, info);
|
2010-09-06 06:04:26 -06:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
info->var.xoffset = var->xoffset;
|
|
|
|
info->var.yoffset = var->yoffset;
|
|
|
|
if (var->vmode & FB_VMODE_YWRAP)
|
|
|
|
info->var.vmode |= FB_VMODE_YWRAP;
|
|
|
|
else
|
|
|
|
info->var.vmode &= ~FB_VMODE_YWRAP;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int XGIfb_blank(int blank, struct fb_info *info)
|
|
|
|
{
|
2011-10-11 12:47:30 -06:00
|
|
|
struct xgifb_video_info *xgifb_info = info->par;
|
2010-05-19 02:44:14 -06:00
|
|
|
u8 reg;
|
|
|
|
|
2011-04-18 13:13:58 -06:00
|
|
|
reg = xgifb_reg_get(XGICR, 0x17);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
if (blank > 0)
|
2010-05-19 02:44:14 -06:00
|
|
|
reg &= 0x7f;
|
|
|
|
else
|
|
|
|
reg |= 0x80;
|
|
|
|
|
2011-04-18 13:13:59 -06:00
|
|
|
xgifb_reg_set(XGICR, 0x17, reg);
|
|
|
|
xgifb_reg_set(XGISR, 0x00, 0x01); /* Synchronous Reset */
|
|
|
|
xgifb_reg_set(XGISR, 0x00, 0x03); /* End Reset */
|
2010-09-06 06:04:26 -06:00
|
|
|
return 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct fb_ops XGIfb_ops = {
|
2010-09-06 06:04:26 -06:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.fb_open = XGIfb_open,
|
|
|
|
.fb_release = XGIfb_release,
|
2010-05-19 02:44:14 -06:00
|
|
|
.fb_check_var = XGIfb_check_var,
|
2010-09-06 06:04:26 -06:00
|
|
|
.fb_set_par = XGIfb_set_par,
|
2010-05-19 02:44:14 -06:00
|
|
|
.fb_setcolreg = XGIfb_setcolreg,
|
2010-09-06 06:04:26 -06:00
|
|
|
.fb_pan_display = XGIfb_pan_display,
|
|
|
|
.fb_blank = XGIfb_blank,
|
2011-02-28 11:59:22 -07:00
|
|
|
.fb_fillrect = cfb_fillrect,
|
2011-02-28 11:59:21 -07:00
|
|
|
.fb_copyarea = cfb_copyarea,
|
2010-05-19 02:44:14 -06:00
|
|
|
.fb_imageblit = cfb_imageblit,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ---------------- Chip generation dependent routines ---------------- */
|
|
|
|
|
|
|
|
/* for XGI 315/550/650/740/330 */
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
static int XGIfb_get_dram_size(struct xgifb_video_info *xgifb_info)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
u8 ChannelNum, tmp;
|
|
|
|
u8 reg = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
/* xorg driver sets 32MB * 1 channel */
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->chip == XG27)
|
2012-01-15 11:22:12 -07:00
|
|
|
xgifb_reg_set(XGISR, IND_SIS_DRAM_SIZE, 0x51);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-01-15 11:22:12 -07:00
|
|
|
reg = xgifb_reg_get(XGISR, IND_SIS_DRAM_SIZE);
|
2012-09-12 15:45:42 -06:00
|
|
|
if (!reg)
|
|
|
|
return -1;
|
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
switch ((reg & XGI_DRAM_SIZE_MASK) >> 4) {
|
|
|
|
case XGI_DRAM_SIZE_1MB:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size = 0x100000;
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
case XGI_DRAM_SIZE_2MB:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size = 0x200000;
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
case XGI_DRAM_SIZE_4MB:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size = 0x400000;
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
case XGI_DRAM_SIZE_8MB:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size = 0x800000;
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
case XGI_DRAM_SIZE_16MB:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size = 0x1000000;
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
case XGI_DRAM_SIZE_32MB:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size = 0x2000000;
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
case XGI_DRAM_SIZE_64MB:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size = 0x4000000;
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
case XGI_DRAM_SIZE_128MB:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size = 0x8000000;
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
case XGI_DRAM_SIZE_256MB:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size = 0x10000000;
|
2010-09-06 06:04:26 -06:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
tmp = (reg & 0x0c) >> 2;
|
2011-10-11 12:47:19 -06:00
|
|
|
switch (xgifb_info->chip) {
|
2010-09-06 06:04:26 -06:00
|
|
|
case XG20:
|
|
|
|
case XG21:
|
|
|
|
case XG27:
|
|
|
|
ChannelNum = 1;
|
|
|
|
break;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
case XG42:
|
|
|
|
if (reg & 0x04)
|
|
|
|
ChannelNum = 2;
|
|
|
|
else
|
|
|
|
ChannelNum = 1;
|
|
|
|
break;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
case XG40:
|
|
|
|
default:
|
|
|
|
if (tmp == 2)
|
|
|
|
ChannelNum = 2;
|
|
|
|
else if (tmp == 3)
|
|
|
|
ChannelNum = 3;
|
|
|
|
else
|
|
|
|
ChannelNum = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size = xgifb_info->video_size * ChannelNum;
|
2010-09-06 06:04:26 -06:00
|
|
|
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_info("SR14=%x DramSzie %x ChannelNum %x\n",
|
2011-04-25 22:13:43 -06:00
|
|
|
reg,
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size, ChannelNum);
|
2010-09-06 06:04:26 -06:00
|
|
|
return 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2010-09-06 06:04:26 -06:00
|
|
|
u8 cr32, temp = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->TV_plug = xgifb_info->TV_type = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-04-18 13:13:58 -06:00
|
|
|
cr32 = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR32);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-01-15 11:22:12 -07:00
|
|
|
if ((cr32 & SIS_CRT1) && !XGIfb_crt1off)
|
2010-05-19 02:44:14 -06:00
|
|
|
XGIfb_crt1off = 0;
|
|
|
|
else {
|
|
|
|
if (cr32 & 0x5F)
|
|
|
|
XGIfb_crt1off = 1;
|
|
|
|
else
|
|
|
|
XGIfb_crt1off = 0;
|
|
|
|
}
|
|
|
|
|
2011-12-05 15:10:48 -07:00
|
|
|
if (!xgifb_info->display2_force) {
|
2012-01-15 11:22:12 -07:00
|
|
|
if (cr32 & SIS_VB_TV)
|
2011-12-05 15:10:48 -07:00
|
|
|
xgifb_info->display2 = XGIFB_DISP_TV;
|
2012-01-15 11:22:12 -07:00
|
|
|
else if (cr32 & SIS_VB_LCD)
|
2011-12-05 15:10:48 -07:00
|
|
|
xgifb_info->display2 = XGIFB_DISP_LCD;
|
2012-01-15 11:22:12 -07:00
|
|
|
else if (cr32 & SIS_VB_CRT2)
|
2011-12-05 15:10:48 -07:00
|
|
|
xgifb_info->display2 = XGIFB_DISP_CRT;
|
|
|
|
else
|
|
|
|
xgifb_info->display2 = XGIFB_DISP_NONE;
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
if (XGIfb_tvplug != -1)
|
2012-07-06 04:40:36 -06:00
|
|
|
/* Override with option */
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->TV_plug = XGIfb_tvplug;
|
2012-01-15 11:22:12 -07:00
|
|
|
else if (cr32 & SIS_VB_HIVISION) {
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->TV_type = TVMODE_HIVISION;
|
|
|
|
xgifb_info->TV_plug = TVPLUG_SVIDEO;
|
2012-01-15 11:22:12 -07:00
|
|
|
} else if (cr32 & SIS_VB_SVIDEO)
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->TV_plug = TVPLUG_SVIDEO;
|
2012-01-15 11:22:12 -07:00
|
|
|
else if (cr32 & SIS_VB_COMPOSITE)
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->TV_plug = TVPLUG_COMPOSITE;
|
2012-01-15 11:22:12 -07:00
|
|
|
else if (cr32 & SIS_VB_SCART)
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->TV_plug = TVPLUG_SCART;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->TV_type == 0) {
|
2011-04-18 13:13:58 -06:00
|
|
|
temp = xgifb_reg_get(XGICR, 0x38);
|
2011-03-13 04:26:08 -06:00
|
|
|
if (temp & 0x10)
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->TV_type = TVMODE_PAL;
|
2011-03-13 04:26:08 -06:00
|
|
|
else
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->TV_type = TVMODE_NTSC;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
/* Copy forceCRT1 option to CRT1off if option is given */
|
2010-09-06 06:04:26 -06:00
|
|
|
if (XGIfb_forcecrt1 != -1) {
|
|
|
|
if (XGIfb_forcecrt1)
|
|
|
|
XGIfb_crt1off = 0;
|
|
|
|
else
|
|
|
|
XGIfb_crt1off = 1;
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
static int XGIfb_has_VB(struct xgifb_video_info *xgifb_info)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
|
|
|
u8 vb_chipid;
|
|
|
|
|
2011-04-18 13:13:58 -06:00
|
|
|
vb_chipid = xgifb_reg_get(XGIPART4, 0x00);
|
2010-05-19 02:44:14 -06:00
|
|
|
switch (vb_chipid) {
|
2010-09-06 06:04:26 -06:00
|
|
|
case 0x01:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->hasVB = HASVB_301;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
case 0x02:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->hasVB = HASVB_302;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
default:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->hasVB = HASVB_NONE;
|
2010-06-17 11:10:42 -06:00
|
|
|
return 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
2010-06-17 11:10:42 -06:00
|
|
|
return 1;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
static void XGIfb_get_VB_type(struct xgifb_video_info *xgifb_info)
|
2011-04-18 13:14:05 -06:00
|
|
|
{
|
|
|
|
u8 reg;
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (!XGIfb_has_VB(xgifb_info)) {
|
2011-04-18 13:14:05 -06:00
|
|
|
reg = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR37);
|
2012-01-15 11:22:12 -07:00
|
|
|
switch ((reg & SIS_EXTERNAL_CHIP_MASK) >> 1) {
|
|
|
|
case SIS_EXTERNAL_CHIP_LVDS:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->hasVB = HASVB_LVDS;
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
2012-01-15 11:22:12 -07:00
|
|
|
case SIS_EXTERNAL_CHIP_LVDS_CHRONTEL:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->hasVB = HASVB_LVDS_CHRONTEL;
|
2011-04-18 13:14:05 -06:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-29 14:14:23 -06:00
|
|
|
static int __init xgifb_optval(char *fullopt, int validx)
|
|
|
|
{
|
|
|
|
unsigned long lres;
|
|
|
|
|
|
|
|
if (kstrtoul(fullopt + validx, 0, &lres) < 0 || lres > INT_MAX) {
|
2012-07-06 04:40:40 -06:00
|
|
|
pr_err("Invalid value for option: %s\n", fullopt);
|
2011-08-29 14:14:23 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return lres;
|
|
|
|
}
|
|
|
|
|
2011-07-21 02:59:11 -06:00
|
|
|
static int __init XGIfb_setup(char *options)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
|
|
|
char *this_opt;
|
|
|
|
|
|
|
|
if (!options || !*options)
|
|
|
|
return 0;
|
|
|
|
|
2012-07-06 04:40:40 -06:00
|
|
|
pr_info("Options: %s\n", options);
|
2011-08-29 14:14:21 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
while ((this_opt = strsep(&options, ",")) != NULL) {
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
if (!*this_opt)
|
|
|
|
continue;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
if (!strncmp(this_opt, "mode:", 5)) {
|
2011-08-29 14:14:25 -06:00
|
|
|
mode = this_opt + 5;
|
2010-05-19 02:44:14 -06:00
|
|
|
} else if (!strncmp(this_opt, "vesa:", 5)) {
|
2011-08-29 14:14:25 -06:00
|
|
|
vesa = xgifb_optval(this_opt, 5);
|
2010-05-19 02:44:14 -06:00
|
|
|
} else if (!strncmp(this_opt, "vrate:", 6)) {
|
2011-10-11 12:47:17 -06:00
|
|
|
refresh_rate = xgifb_optval(this_opt, 6);
|
2010-05-19 02:44:14 -06:00
|
|
|
} else if (!strncmp(this_opt, "rate:", 5)) {
|
2011-10-11 12:47:17 -06:00
|
|
|
refresh_rate = xgifb_optval(this_opt, 5);
|
2010-05-19 02:44:14 -06:00
|
|
|
} else if (!strncmp(this_opt, "crt1off", 7)) {
|
|
|
|
XGIfb_crt1off = 1;
|
|
|
|
} else if (!strncmp(this_opt, "filter:", 7)) {
|
2011-08-29 14:14:23 -06:00
|
|
|
filter = xgifb_optval(this_opt, 7);
|
2010-05-19 02:44:14 -06:00
|
|
|
} else if (!strncmp(this_opt, "forcecrt2type:", 14)) {
|
|
|
|
XGIfb_search_crt2type(this_opt + 14);
|
|
|
|
} else if (!strncmp(this_opt, "forcecrt1:", 10)) {
|
2011-08-29 14:14:23 -06:00
|
|
|
XGIfb_forcecrt1 = xgifb_optval(this_opt, 10);
|
2010-09-06 06:04:26 -06:00
|
|
|
} else if (!strncmp(this_opt, "tvmode:", 7)) {
|
|
|
|
XGIfb_search_tvstd(this_opt + 7);
|
|
|
|
} else if (!strncmp(this_opt, "tvstandard:", 11)) {
|
2010-05-19 02:44:14 -06:00
|
|
|
XGIfb_search_tvstd(this_opt + 7);
|
2010-09-06 06:04:26 -06:00
|
|
|
} else if (!strncmp(this_opt, "dstn", 4)) {
|
2010-05-19 02:44:14 -06:00
|
|
|
enable_dstn = 1;
|
2012-07-06 04:40:36 -06:00
|
|
|
/* DSTN overrules forcecrt2type */
|
2011-10-11 12:47:37 -06:00
|
|
|
XGIfb_crt2type = XGIFB_DISP_LCD;
|
2010-05-19 02:44:14 -06:00
|
|
|
} else if (!strncmp(this_opt, "noypan", 6)) {
|
2010-09-06 06:04:26 -06:00
|
|
|
XGIfb_ypan = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
} else {
|
2011-08-29 14:14:25 -06:00
|
|
|
mode = this_opt;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-19 11:21:52 -07:00
|
|
|
static int xgifb_probe(struct pci_dev *pdev,
|
2010-09-06 06:04:26 -06:00
|
|
|
const struct pci_device_id *ent)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2010-09-06 06:04:26 -06:00
|
|
|
u8 reg, reg1;
|
|
|
|
u8 CR48, CR38;
|
2011-02-17 14:29:11 -07:00
|
|
|
int ret;
|
2011-10-11 12:47:14 -06:00
|
|
|
struct fb_info *fb_info;
|
2011-10-11 12:47:20 -06:00
|
|
|
struct xgifb_video_info *xgifb_info;
|
|
|
|
struct xgi_hw_device_info *hw_info;
|
2012-09-11 15:44:38 -06:00
|
|
|
unsigned long video_size_max;
|
2011-02-17 14:29:11 -07:00
|
|
|
|
2011-10-11 12:47:20 -06:00
|
|
|
fb_info = framebuffer_alloc(sizeof(*xgifb_info), &pdev->dev);
|
2010-09-06 06:04:26 -06:00
|
|
|
if (!fb_info)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2011-10-11 12:47:20 -06:00
|
|
|
xgifb_info = fb_info->par;
|
|
|
|
hw_info = &xgifb_info->hw_info;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->fb_info = fb_info;
|
|
|
|
xgifb_info->chip_id = pdev->device;
|
2011-04-25 22:13:43 -06:00
|
|
|
pci_read_config_byte(pdev,
|
|
|
|
PCI_REVISION_ID,
|
2011-10-11 12:47:19 -06:00
|
|
|
&xgifb_info->revision_id);
|
|
|
|
hw_info->jChipRevision = xgifb_info->revision_id;
|
|
|
|
|
|
|
|
xgifb_info->pcibus = pdev->bus->number;
|
|
|
|
xgifb_info->pcislot = PCI_SLOT(pdev->devfn);
|
|
|
|
xgifb_info->pcifunc = PCI_FUNC(pdev->devfn);
|
|
|
|
xgifb_info->subsysvendor = pdev->subsystem_vendor;
|
|
|
|
xgifb_info->subsysdevice = pdev->subsystem_device;
|
|
|
|
|
2012-09-11 15:44:38 -06:00
|
|
|
video_size_max = pci_resource_len(pdev, 0);
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_base = pci_resource_start(pdev, 0);
|
|
|
|
xgifb_info->mmio_base = pci_resource_start(pdev, 1);
|
|
|
|
xgifb_info->mmio_size = pci_resource_len(pdev, 1);
|
|
|
|
xgifb_info->vga_base = pci_resource_start(pdev, 2) + 0x30;
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev, "Relocate IO address: %Lx [%08lx]\n",
|
|
|
|
(u64) pci_resource_start(pdev, 2),
|
|
|
|
xgifb_info->vga_base);
|
2010-09-06 06:04:26 -06:00
|
|
|
|
2011-02-17 14:29:11 -07:00
|
|
|
if (pci_enable_device(pdev)) {
|
|
|
|
ret = -EIO;
|
|
|
|
goto error;
|
|
|
|
}
|
2010-09-06 06:04:26 -06:00
|
|
|
|
2011-12-05 15:10:48 -07:00
|
|
|
if (XGIfb_crt2type != -1) {
|
|
|
|
xgifb_info->display2 = XGIfb_crt2type;
|
|
|
|
xgifb_info->display2_force = true;
|
|
|
|
}
|
|
|
|
|
2012-03-19 11:50:13 -06:00
|
|
|
XGIRegInit(&xgifb_info->dev_info, xgifb_info->vga_base);
|
2010-09-06 06:04:26 -06:00
|
|
|
|
2012-01-15 11:22:12 -07:00
|
|
|
xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD);
|
|
|
|
reg1 = xgifb_reg_get(XGISR, IND_SIS_PASSWORD);
|
2010-09-06 06:04:26 -06:00
|
|
|
|
|
|
|
if (reg1 != 0xa1) { /*I/O error */
|
2012-07-06 04:40:40 -06:00
|
|
|
dev_err(&pdev->dev, "I/O error\n");
|
2011-02-17 14:29:11 -07:00
|
|
|
ret = -EIO;
|
2012-06-06 08:22:06 -06:00
|
|
|
goto error_disable;
|
2010-09-06 06:04:26 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
switch (xgifb_info->chip_id) {
|
2012-01-15 11:22:12 -07:00
|
|
|
case PCI_DEVICE_ID_XGI_20:
|
2011-04-18 13:14:00 -06:00
|
|
|
xgifb_reg_or(XGICR, Index_CR_GPIO_Reg3, GPIOG_EN);
|
2011-04-18 13:13:58 -06:00
|
|
|
CR48 = xgifb_reg_get(XGICR, Index_CR_GPIO_Reg1);
|
2010-05-19 02:44:14 -06:00
|
|
|
if (CR48&GPIOG_READ)
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->chip = XG21;
|
2010-05-19 02:44:14 -06:00
|
|
|
else
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->chip = XG20;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2012-01-15 11:22:12 -07:00
|
|
|
case PCI_DEVICE_ID_XGI_40:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->chip = XG40;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2012-01-15 11:22:12 -07:00
|
|
|
case PCI_DEVICE_ID_XGI_42:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->chip = XG42;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2012-01-15 11:22:12 -07:00
|
|
|
case PCI_DEVICE_ID_XGI_27:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->chip = XG27;
|
2010-05-19 02:44:14 -06:00
|
|
|
break;
|
2010-09-06 06:04:26 -06:00
|
|
|
default:
|
2011-02-17 14:29:11 -07:00
|
|
|
ret = -ENODEV;
|
2012-06-06 08:22:06 -06:00
|
|
|
goto error_disable;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev, "chipid = %x\n", xgifb_info->chip);
|
2011-10-11 12:47:19 -06:00
|
|
|
hw_info->jChipType = xgifb_info->chip;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (XGIfb_get_dram_size(xgifb_info)) {
|
2012-09-12 15:45:42 -06:00
|
|
|
xgifb_info->video_size = min_t(unsigned long, video_size_max,
|
|
|
|
SZ_16M);
|
2012-09-11 15:44:38 -06:00
|
|
|
} else if (xgifb_info->video_size > video_size_max) {
|
|
|
|
xgifb_info->video_size = video_size_max;
|
2010-09-06 06:04:26 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-08-19 13:40:26 -06:00
|
|
|
/* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */
|
|
|
|
xgifb_reg_or(XGISR,
|
2012-01-15 11:22:12 -07:00
|
|
|
IND_SIS_PCI_ADDRESS_SET,
|
|
|
|
(SIS_PCI_ADDR_ENABLE | SIS_MEM_MAP_IO_ENABLE));
|
2011-08-19 13:40:26 -06:00
|
|
|
/* Enable 2D accelerator engine */
|
2012-01-15 11:22:12 -07:00
|
|
|
xgifb_reg_or(XGISR, IND_SIS_MODULE_ENABLE, SIS_ENABLE_2D);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
hw_info->ulVideoMemorySize = xgifb_info->video_size;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (!request_mem_region(xgifb_info->video_base,
|
|
|
|
xgifb_info->video_size,
|
2011-04-25 22:13:43 -06:00
|
|
|
"XGIfb FB")) {
|
2012-07-06 04:40:40 -06:00
|
|
|
dev_err(&pdev->dev, "Unable request memory size %x\n",
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_size);
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_err(&pdev->dev,
|
2014-02-27 21:45:56 -07:00
|
|
|
"Fatal error: Unable to reserve frame buffer memory. Is there another framebuffer driver active?\n");
|
2011-02-17 14:29:11 -07:00
|
|
|
ret = -ENODEV;
|
2012-06-06 08:22:06 -06:00
|
|
|
goto error_disable;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (!request_mem_region(xgifb_info->mmio_base,
|
|
|
|
xgifb_info->mmio_size,
|
2011-02-17 14:29:17 -07:00
|
|
|
"XGIfb MMIO")) {
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_err(&pdev->dev,
|
|
|
|
"Fatal error: Unable to reserve MMIO region\n");
|
2011-02-17 14:29:11 -07:00
|
|
|
ret = -ENODEV;
|
2011-02-17 14:29:15 -07:00
|
|
|
goto error_0;
|
2010-09-06 06:04:26 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_vbase = hw_info->pjVideoMemoryAddress =
|
staging: xgifb: use arch_phys_wc_add() and ioremap_wc()
The same area used for ioremap() is used for the MTRR area.
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.
There are a few motivations for this:
a) Take advantage of PAT when available
b) Help bury MTRR code away, MTRR is architecture specific and on
x86 its replaced by PAT
c) Help with the goal of eventually using _PAGE_CACHE_UC over
_PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
de33c442e titled "x86 PAT: fix performance drop for glx,
use UC minus for ioremap(), ioremap_nocache() and
pci_mmap_page_range()")
The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.
@ mtrr_found @
expression index, base, size;
@@
-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);
@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@
-mtrr_del(index, base, size);
+arch_phys_wc_del(index);
@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@
-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);
@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@
-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);
@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);
@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);
Generated-by: Coccinelle SmPL
Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Brian Vandre <bvandre@gmail.com>
Cc: Thomas Gummerer <t.gummerer@gmail.com>
Cc: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
Cc: Lubomir Rintel <lkundrak@v3.sk>
Cc: Vitor Braga <vitorpybraga@gmail.com>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: devel@driverdev.osuosl.org
Cc: linux-fbdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-28 13:39:07 -06:00
|
|
|
ioremap_wc(xgifb_info->video_base, xgifb_info->video_size);
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base,
|
|
|
|
xgifb_info->mmio_size);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"Framebuffer at 0x%Lx, mapped to 0x%p, size %dk\n",
|
|
|
|
(u64) xgifb_info->video_base,
|
|
|
|
xgifb_info->video_vbase,
|
|
|
|
xgifb_info->video_size / 1024);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"MMIO at 0x%Lx, mapped to 0x%p, size %ldk\n",
|
|
|
|
(u64) xgifb_info->mmio_base, xgifb_info->mmio_vbase,
|
|
|
|
xgifb_info->mmio_size / 1024);
|
2012-01-22 17:48:53 -07:00
|
|
|
|
2011-10-11 12:47:20 -06:00
|
|
|
pci_set_drvdata(pdev, xgifb_info);
|
2012-01-22 17:48:53 -07:00
|
|
|
if (!XGIInitNew(pdev))
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_err(&pdev->dev, "XGIInitNew() failed!\n");
|
2010-09-06 06:04:26 -06:00
|
|
|
|
2013-02-03 14:54:32 -07:00
|
|
|
xgifb_info->mtrr = -1;
|
2010-09-06 06:04:26 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->hasVB = HASVB_NONE;
|
|
|
|
if ((xgifb_info->chip == XG20) ||
|
|
|
|
(xgifb_info->chip == XG27)) {
|
|
|
|
xgifb_info->hasVB = HASVB_NONE;
|
|
|
|
} else if (xgifb_info->chip == XG21) {
|
2011-08-19 13:40:26 -06:00
|
|
|
CR38 = xgifb_reg_get(XGICR, 0x38);
|
2012-01-22 17:48:51 -07:00
|
|
|
if ((CR38&0xE0) == 0xC0)
|
2011-10-11 12:47:37 -06:00
|
|
|
xgifb_info->display2 = XGIFB_DISP_LCD;
|
2012-01-22 17:48:51 -07:00
|
|
|
else if ((CR38&0xE0) == 0x60)
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->hasVB = HASVB_CHRONTEL;
|
2012-01-22 17:48:51 -07:00
|
|
|
else
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->hasVB = HASVB_NONE;
|
2011-08-19 13:40:26 -06:00
|
|
|
} else {
|
2011-10-11 12:47:19 -06:00
|
|
|
XGIfb_get_VB_type(xgifb_info);
|
2011-08-19 13:40:26 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ujVBChipID = VB_CHIP_UNKNOWN;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ulExternalChip = 0;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
switch (xgifb_info->hasVB) {
|
2011-08-19 13:40:26 -06:00
|
|
|
case HASVB_301:
|
|
|
|
reg = xgifb_reg_get(XGIPART4, 0x01);
|
|
|
|
if (reg >= 0xE0) {
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ujVBChipID = VB_CHIP_302LV;
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"XGI302LV bridge detected (revision 0x%02x)\n",
|
|
|
|
reg);
|
2011-08-19 13:40:26 -06:00
|
|
|
} else if (reg >= 0xD0) {
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ujVBChipID = VB_CHIP_301LV;
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"XGI301LV bridge detected (revision 0x%02x)\n",
|
|
|
|
reg);
|
2012-07-06 04:40:36 -06:00
|
|
|
} else {
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ujVBChipID = VB_CHIP_301;
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev, "XGI301 bridge detected\n");
|
2011-08-19 13:40:26 -06:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case HASVB_302:
|
|
|
|
reg = xgifb_reg_get(XGIPART4, 0x01);
|
|
|
|
if (reg >= 0xE0) {
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ujVBChipID = VB_CHIP_302LV;
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"XGI302LV bridge detected (revision 0x%02x)\n",
|
|
|
|
reg);
|
2011-08-19 13:40:26 -06:00
|
|
|
} else if (reg >= 0xD0) {
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ujVBChipID = VB_CHIP_301LV;
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"XGI302LV bridge detected (revision 0x%02x)\n",
|
|
|
|
reg);
|
2011-08-19 13:40:26 -06:00
|
|
|
} else if (reg >= 0xB0) {
|
|
|
|
reg1 = xgifb_reg_get(XGIPART4, 0x23);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ujVBChipID = VB_CHIP_302B;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
} else {
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ujVBChipID = VB_CHIP_302;
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev, "XGI302 bridge detected\n");
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
2011-08-19 13:40:26 -06:00
|
|
|
break;
|
|
|
|
case HASVB_LVDS:
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ulExternalChip = 0x1;
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev, "LVDS transmitter detected\n");
|
2011-08-19 13:40:26 -06:00
|
|
|
break;
|
|
|
|
case HASVB_TRUMPION:
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ulExternalChip = 0x2;
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev, "Trumpion Zurac LVDS scaler detected\n");
|
2011-08-19 13:40:26 -06:00
|
|
|
break;
|
|
|
|
case HASVB_CHRONTEL:
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ulExternalChip = 0x4;
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev, "Chrontel TV encoder detected\n");
|
2011-08-19 13:40:26 -06:00
|
|
|
break;
|
|
|
|
case HASVB_LVDS_CHRONTEL:
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ulExternalChip = 0x5;
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"LVDS transmitter and Chrontel TV encoder detected\n");
|
2011-08-19 13:40:26 -06:00
|
|
|
break;
|
|
|
|
default:
|
2012-06-18 05:12:06 -06:00
|
|
|
dev_info(&pdev->dev, "No or unknown bridge type detected\n");
|
2011-08-19 13:40:26 -06:00
|
|
|
break;
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:19 -06:00
|
|
|
if (xgifb_info->hasVB != HASVB_NONE)
|
|
|
|
XGIfb_detect_VB(xgifb_info);
|
2011-12-05 15:10:48 -07:00
|
|
|
else if (xgifb_info->chip != XG21)
|
|
|
|
xgifb_info->display2 = XGIFB_DISP_NONE;
|
2010-09-06 06:04:26 -06:00
|
|
|
|
2011-10-11 12:47:37 -06:00
|
|
|
if (xgifb_info->display2 == XGIFB_DISP_LCD) {
|
2011-08-19 13:40:26 -06:00
|
|
|
if (!enable_dstn) {
|
|
|
|
reg = xgifb_reg_get(XGICR, IND_XGI_LCD_PANEL);
|
|
|
|
reg &= 0x0f;
|
2011-10-11 12:47:15 -06:00
|
|
|
hw_info->ulCRT2LCDType = XGI310paneltype[reg];
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
2011-08-19 13:40:26 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->mode_idx = -1;
|
|
|
|
|
2011-08-29 14:14:25 -06:00
|
|
|
if (mode)
|
2011-10-11 12:47:22 -06:00
|
|
|
XGIfb_search_mode(xgifb_info, mode);
|
2011-08-29 14:14:25 -06:00
|
|
|
else if (vesa != -1)
|
2011-10-11 12:47:22 -06:00
|
|
|
XGIfb_search_vesamode(xgifb_info, vesa);
|
2011-08-29 14:14:25 -06:00
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
if (xgifb_info->mode_idx >= 0)
|
|
|
|
xgifb_info->mode_idx =
|
|
|
|
XGIfb_validate_mode(xgifb_info, xgifb_info->mode_idx);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
if (xgifb_info->mode_idx < 0) {
|
2011-10-11 12:47:37 -06:00
|
|
|
if (xgifb_info->display2 == XGIFB_DISP_LCD &&
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->chip == XG21)
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->mode_idx =
|
2011-12-05 15:10:45 -07:00
|
|
|
XGIfb_GetXG21DefaultLVDSModeIdx(xgifb_info);
|
2011-08-29 14:14:30 -06:00
|
|
|
else
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->mode_idx = DEFAULT_MODE;
|
2011-08-19 13:40:26 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
if (xgifb_info->mode_idx < 0) {
|
2012-07-06 04:40:40 -06:00
|
|
|
dev_err(&pdev->dev, "No supported video mode found\n");
|
2013-02-03 14:54:33 -07:00
|
|
|
ret = -EINVAL;
|
2011-08-29 14:14:29 -06:00
|
|
|
goto error_1;
|
|
|
|
}
|
|
|
|
|
2012-07-06 04:40:36 -06:00
|
|
|
/* set default refresh rate */
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->refresh_rate = refresh_rate;
|
|
|
|
if (xgifb_info->refresh_rate == 0)
|
|
|
|
xgifb_info->refresh_rate = 60;
|
|
|
|
if (XGIfb_search_refresh_rate(xgifb_info,
|
|
|
|
xgifb_info->refresh_rate) == 0) {
|
2012-04-06 16:13:54 -06:00
|
|
|
xgifb_info->rate_idx = 1;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->refresh_rate = 60;
|
2011-08-19 13:40:26 -06:00
|
|
|
}
|
|
|
|
|
2011-10-11 12:47:22 -06:00
|
|
|
xgifb_info->video_bpp = XGIbios_mode[xgifb_info->mode_idx].bpp;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_vwidth =
|
|
|
|
xgifb_info->video_width =
|
2011-10-11 12:47:22 -06:00
|
|
|
XGIbios_mode[xgifb_info->mode_idx].xres;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_vheight =
|
|
|
|
xgifb_info->video_height =
|
2011-10-11 12:47:22 -06:00
|
|
|
XGIbios_mode[xgifb_info->mode_idx].yres;
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->org_x = xgifb_info->org_y = 0;
|
|
|
|
xgifb_info->video_linelength =
|
|
|
|
xgifb_info->video_width *
|
|
|
|
(xgifb_info->video_bpp >> 3);
|
|
|
|
switch (xgifb_info->video_bpp) {
|
2011-08-19 13:40:26 -06:00
|
|
|
case 8:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->DstColor = 0x0000;
|
|
|
|
xgifb_info->XGI310_AccelDepth = 0x00000000;
|
|
|
|
xgifb_info->video_cmap_len = 256;
|
2011-08-19 13:40:26 -06:00
|
|
|
break;
|
|
|
|
case 16:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->DstColor = 0x8000;
|
|
|
|
xgifb_info->XGI310_AccelDepth = 0x00010000;
|
|
|
|
xgifb_info->video_cmap_len = 16;
|
2011-08-19 13:40:26 -06:00
|
|
|
break;
|
|
|
|
case 32:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->DstColor = 0xC000;
|
|
|
|
xgifb_info->XGI310_AccelDepth = 0x00020000;
|
|
|
|
xgifb_info->video_cmap_len = 16;
|
2011-08-19 13:40:26 -06:00
|
|
|
break;
|
|
|
|
default:
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_cmap_len = 16;
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_info("Unsupported depth %d\n",
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_bpp);
|
2011-08-19 13:40:26 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_info("Default mode is %dx%dx%d (%dHz)\n",
|
2011-10-11 12:47:19 -06:00
|
|
|
xgifb_info->video_width,
|
|
|
|
xgifb_info->video_height,
|
|
|
|
xgifb_info->video_bpp,
|
|
|
|
xgifb_info->refresh_rate);
|
2011-08-19 13:40:26 -06:00
|
|
|
|
2011-10-11 12:47:26 -06:00
|
|
|
fb_info->var.red.length = 8;
|
|
|
|
fb_info->var.green.length = 8;
|
|
|
|
fb_info->var.blue.length = 8;
|
|
|
|
fb_info->var.activate = FB_ACTIVATE_NOW;
|
|
|
|
fb_info->var.height = -1;
|
|
|
|
fb_info->var.width = -1;
|
|
|
|
fb_info->var.vmode = FB_VMODE_NONINTERLACED;
|
|
|
|
fb_info->var.xres = xgifb_info->video_width;
|
|
|
|
fb_info->var.xres_virtual = xgifb_info->video_width;
|
|
|
|
fb_info->var.yres = xgifb_info->video_height;
|
|
|
|
fb_info->var.yres_virtual = xgifb_info->video_height;
|
|
|
|
fb_info->var.bits_per_pixel = xgifb_info->video_bpp;
|
|
|
|
|
|
|
|
XGIfb_bpp_to_var(xgifb_info, &fb_info->var);
|
|
|
|
|
|
|
|
fb_info->var.pixclock = (u32) (1000000000 /
|
2011-10-11 12:47:30 -06:00
|
|
|
XGIfb_mode_rate_to_dclock(&xgifb_info->dev_info,
|
|
|
|
hw_info,
|
2013-07-16 14:13:25 -06:00
|
|
|
XGIbios_mode[xgifb_info->mode_idx].mode_no));
|
2011-08-19 13:40:26 -06:00
|
|
|
|
2011-10-11 12:47:30 -06:00
|
|
|
if (XGIfb_mode_rate_to_ddata(&xgifb_info->dev_info, hw_info,
|
2011-10-11 12:47:23 -06:00
|
|
|
XGIbios_mode[xgifb_info->mode_idx].mode_no,
|
2011-10-11 12:47:26 -06:00
|
|
|
&fb_info->var.left_margin,
|
|
|
|
&fb_info->var.right_margin,
|
|
|
|
&fb_info->var.upper_margin,
|
|
|
|
&fb_info->var.lower_margin,
|
|
|
|
&fb_info->var.hsync_len,
|
|
|
|
&fb_info->var.vsync_len,
|
|
|
|
&fb_info->var.sync,
|
|
|
|
&fb_info->var.vmode)) {
|
|
|
|
|
|
|
|
if ((fb_info->var.vmode & FB_VMODE_MASK) ==
|
2011-08-19 13:40:26 -06:00
|
|
|
FB_VMODE_INTERLACED) {
|
2011-10-11 12:47:26 -06:00
|
|
|
fb_info->var.yres <<= 1;
|
|
|
|
fb_info->var.yres_virtual <<= 1;
|
|
|
|
} else if ((fb_info->var.vmode & FB_VMODE_MASK) ==
|
2011-08-19 13:40:26 -06:00
|
|
|
FB_VMODE_DOUBLE) {
|
2011-10-11 12:47:26 -06:00
|
|
|
fb_info->var.pixclock >>= 1;
|
|
|
|
fb_info->var.yres >>= 1;
|
|
|
|
fb_info->var.yres_virtual >>= 1;
|
2010-09-06 06:04:26 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-08-19 13:40:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fb_info->flags = FBINFO_FLAG_DEFAULT;
|
2011-10-11 12:47:19 -06:00
|
|
|
fb_info->screen_base = xgifb_info->video_vbase;
|
2011-08-19 13:40:26 -06:00
|
|
|
fb_info->fbops = &XGIfb_ops;
|
|
|
|
XGIfb_get_fix(&fb_info->fix, -1, fb_info);
|
2011-10-11 12:47:24 -06:00
|
|
|
fb_info->pseudo_palette = xgifb_info->pseudo_palette;
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2014-10-29 06:02:23 -06:00
|
|
|
fb_alloc_cmap(&fb_info->cmap, 256, 0);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
staging: xgifb: use arch_phys_wc_add() and ioremap_wc()
The same area used for ioremap() is used for the MTRR area.
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.
There are a few motivations for this:
a) Take advantage of PAT when available
b) Help bury MTRR code away, MTRR is architecture specific and on
x86 its replaced by PAT
c) Help with the goal of eventually using _PAGE_CACHE_UC over
_PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
de33c442e titled "x86 PAT: fix performance drop for glx,
use UC minus for ioremap(), ioremap_nocache() and
pci_mmap_page_range()")
The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.
@ mtrr_found @
expression index, base, size;
@@
-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);
@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@
-mtrr_del(index, base, size);
+arch_phys_wc_del(index);
@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@
-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);
@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@
-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);
@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);
@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);
Generated-by: Coccinelle SmPL
Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Brian Vandre <bvandre@gmail.com>
Cc: Thomas Gummerer <t.gummerer@gmail.com>
Cc: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
Cc: Lubomir Rintel <lkundrak@v3.sk>
Cc: Vitor Braga <vitorpybraga@gmail.com>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: devel@driverdev.osuosl.org
Cc: linux-fbdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-28 13:39:07 -06:00
|
|
|
xgifb_info->mtrr = arch_phys_wc_add(xgifb_info->video_base,
|
|
|
|
xgifb_info->video_size);
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2011-08-19 13:40:26 -06:00
|
|
|
if (register_framebuffer(fb_info) < 0) {
|
|
|
|
ret = -EINVAL;
|
2011-09-10 15:29:53 -06:00
|
|
|
goto error_mtrr;
|
2011-08-19 13:40:26 -06:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
dumpVGAReg();
|
|
|
|
|
|
|
|
return 0;
|
2011-02-17 14:29:11 -07:00
|
|
|
|
2011-09-10 15:29:53 -06:00
|
|
|
error_mtrr:
|
staging: xgifb: use arch_phys_wc_add() and ioremap_wc()
The same area used for ioremap() is used for the MTRR area.
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.
There are a few motivations for this:
a) Take advantage of PAT when available
b) Help bury MTRR code away, MTRR is architecture specific and on
x86 its replaced by PAT
c) Help with the goal of eventually using _PAGE_CACHE_UC over
_PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
de33c442e titled "x86 PAT: fix performance drop for glx,
use UC minus for ioremap(), ioremap_nocache() and
pci_mmap_page_range()")
The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.
@ mtrr_found @
expression index, base, size;
@@
-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);
@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@
-mtrr_del(index, base, size);
+arch_phys_wc_del(index);
@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@
-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);
@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@
-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);
@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);
@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);
Generated-by: Coccinelle SmPL
Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Brian Vandre <bvandre@gmail.com>
Cc: Thomas Gummerer <t.gummerer@gmail.com>
Cc: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
Cc: Lubomir Rintel <lkundrak@v3.sk>
Cc: Vitor Braga <vitorpybraga@gmail.com>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: devel@driverdev.osuosl.org
Cc: linux-fbdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-28 13:39:07 -06:00
|
|
|
arch_phys_wc_del(xgifb_info->mtrr);
|
2011-02-17 14:29:15 -07:00
|
|
|
error_1:
|
2011-10-11 12:47:19 -06:00
|
|
|
iounmap(xgifb_info->mmio_vbase);
|
|
|
|
iounmap(xgifb_info->video_vbase);
|
|
|
|
release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size);
|
2011-02-17 14:29:15 -07:00
|
|
|
error_0:
|
2011-10-11 12:47:19 -06:00
|
|
|
release_mem_region(xgifb_info->video_base, xgifb_info->video_size);
|
2012-06-06 08:22:06 -06:00
|
|
|
error_disable:
|
|
|
|
pci_disable_device(pdev);
|
2011-02-17 14:29:11 -07:00
|
|
|
error:
|
|
|
|
framebuffer_release(fb_info);
|
|
|
|
return ret;
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************/
|
|
|
|
/* PCI DEVICE HANDLING */
|
|
|
|
/*****************************************************/
|
|
|
|
|
2012-11-19 11:26:55 -07:00
|
|
|
static void xgifb_remove(struct pci_dev *pdev)
|
2010-05-19 02:44:14 -06:00
|
|
|
{
|
2011-10-11 12:47:18 -06:00
|
|
|
struct xgifb_video_info *xgifb_info = pci_get_drvdata(pdev);
|
2011-10-11 12:47:14 -06:00
|
|
|
struct fb_info *fb_info = xgifb_info->fb_info;
|
2011-10-11 12:47:13 -06:00
|
|
|
|
2010-09-06 06:04:26 -06:00
|
|
|
unregister_framebuffer(fb_info);
|
staging: xgifb: use arch_phys_wc_add() and ioremap_wc()
The same area used for ioremap() is used for the MTRR area.
Convert the driver from using the x86 specific MTRR code to
the architecture agnostic arch_phys_wc_add(). arch_phys_wc_add()
will avoid MTRR if write-combining is available, in order to
take advantage of that also ensure the ioremap'd area is requested
as write-combining.
There are a few motivations for this:
a) Take advantage of PAT when available
b) Help bury MTRR code away, MTRR is architecture specific and on
x86 its replaced by PAT
c) Help with the goal of eventually using _PAGE_CACHE_UC over
_PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
de33c442e titled "x86 PAT: fix performance drop for glx,
use UC minus for ioremap(), ioremap_nocache() and
pci_mmap_page_range()")
The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the #ifdery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get
an MTRR.
@ mtrr_found @
expression index, base, size;
@@
-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);
@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@
-mtrr_del(index, base, size);
+arch_phys_wc_del(index);
@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@
-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);
@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@
-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);
@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);
@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);
Generated-by: Coccinelle SmPL
Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Brian Vandre <bvandre@gmail.com>
Cc: Thomas Gummerer <t.gummerer@gmail.com>
Cc: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
Cc: Lubomir Rintel <lkundrak@v3.sk>
Cc: Vitor Braga <vitorpybraga@gmail.com>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: devel@driverdev.osuosl.org
Cc: linux-fbdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-28 13:39:07 -06:00
|
|
|
arch_phys_wc_del(xgifb_info->mtrr);
|
2011-10-11 12:47:13 -06:00
|
|
|
iounmap(xgifb_info->mmio_vbase);
|
|
|
|
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);
|
2012-06-06 08:22:07 -06:00
|
|
|
pci_disable_device(pdev);
|
2010-09-06 06:04:26 -06:00
|
|
|
framebuffer_release(fb_info);
|
2011-02-17 14:29:16 -07:00
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
static struct pci_driver xgifb_driver = {
|
2010-09-06 06:04:26 -06:00
|
|
|
.name = "xgifb",
|
|
|
|
.id_table = xgifb_pci_table,
|
|
|
|
.probe = xgifb_probe,
|
2012-11-19 11:21:04 -07:00
|
|
|
.remove = xgifb_remove
|
2010-05-19 02:44:14 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************/
|
|
|
|
/* MODULE */
|
|
|
|
/*****************************************************/
|
|
|
|
|
|
|
|
module_param(mode, charp, 0);
|
2012-06-06 08:22:05 -06:00
|
|
|
MODULE_PARM_DESC(mode,
|
2014-02-27 21:45:56 -07:00
|
|
|
"Selects the desired default display mode in the format XxYxDepth (eg. 1024x768x16).");
|
2011-12-05 15:10:49 -07:00
|
|
|
|
2012-06-06 08:22:05 -06:00
|
|
|
module_param(forcecrt2type, charp, 0);
|
2011-12-05 15:10:49 -07:00
|
|
|
MODULE_PARM_DESC(forcecrt2type,
|
2014-02-27 21:45:56 -07:00
|
|
|
"Force the second display output type. Possible values are NONE, LCD, TV, VGA, SVIDEO or COMPOSITE.");
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-06-06 08:22:05 -06:00
|
|
|
module_param(vesa, int, 0);
|
2010-05-19 02:44:14 -06:00
|
|
|
MODULE_PARM_DESC(vesa,
|
2014-02-27 21:45:56 -07:00
|
|
|
"Selects the desired default display mode by VESA mode number (eg. 0x117).");
|
2010-05-19 02:44:14 -06:00
|
|
|
|
2012-06-06 08:22:05 -06:00
|
|
|
module_param(filter, int, 0);
|
2010-05-19 02:44:14 -06:00
|
|
|
MODULE_PARM_DESC(filter,
|
2014-02-27 21:45:56 -07:00
|
|
|
"Selects TV flicker filter type (only for systems with a SiS301 video bridge). Possible values 0-7. Default: [no filter]).");
|
2012-06-06 08:22:05 -06:00
|
|
|
|
|
|
|
static int __init xgifb_init(void)
|
|
|
|
{
|
|
|
|
char *option = NULL;
|
|
|
|
|
|
|
|
if (forcecrt2type != NULL)
|
|
|
|
XGIfb_search_crt2type(forcecrt2type);
|
|
|
|
if (fb_get_options("xgifb", &option))
|
|
|
|
return -ENODEV;
|
|
|
|
XGIfb_setup(option);
|
|
|
|
|
|
|
|
return pci_register_driver(&xgifb_driver);
|
|
|
|
}
|
2010-05-19 02:44:14 -06:00
|
|
|
|
|
|
|
static void __exit xgifb_remove_module(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&xgifb_driver);
|
2012-01-22 17:48:53 -07:00
|
|
|
pr_debug("Module unloaded\n");
|
2010-05-19 02:44:14 -06:00
|
|
|
}
|
|
|
|
|
2012-06-06 08:22:05 -06:00
|
|
|
MODULE_DESCRIPTION("Z7 Z9 Z9S Z11 framebuffer device driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("XGITECH , Others");
|
|
|
|
module_init(xgifb_init);
|
2010-05-19 02:44:14 -06:00
|
|
|
module_exit(xgifb_remove_module);
|