Commit 009adf2d authored by Aaro Koskinen's avatar Aaro Koskinen Committed by Greg Kroah-Hartman

staging: xgifb: fix LVDS LCD resolution data setup

If the driver fails to get LVDS LCD data from the firmware, it falls
back to using driver's hardcoded values. However, this is done too
early in the probe. The selected video mode index is not yet known,
and also in some cases it could be defaulting to -1 resulting in a read
outside the array. Fix this by moving the array lookup after the video
mode validation.
Signed-off-by: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
Reported-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent d27c6bc9
...@@ -2021,6 +2021,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, ...@@ -2021,6 +2021,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
u8 reg, reg1; u8 reg, reg1;
u8 CR48, CR38; u8 CR48, CR38;
int ret; int ret;
bool xgi21_drvlcdcaplist = false;
memset(&XGIhw_ext, 0, sizeof(struct xgi_hw_device_info)); memset(&XGIhw_ext, 0, sizeof(struct xgi_hw_device_info));
fb_info = framebuffer_alloc(sizeof(struct fb_info), &pdev->dev); fb_info = framebuffer_alloc(sizeof(struct fb_info), &pdev->dev);
...@@ -2174,15 +2175,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, ...@@ -2174,15 +2175,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
CR38 = xgifb_reg_get(XGICR, 0x38); CR38 = xgifb_reg_get(XGICR, 0x38);
if ((CR38&0xE0) == 0xC0) { if ((CR38&0xE0) == 0xC0) {
xgi_video_info.disp_state = DISPTYPE_LCD; xgi_video_info.disp_state = DISPTYPE_LCD;
if (!XGIfb_GetXG21LVDSData()) { if (!XGIfb_GetXG21LVDSData())
int m; xgi21_drvlcdcaplist = true;
for (m = 0; m < sizeof(XGI21_LCDCapList)/sizeof(struct XGI21_LVDSCapStruct); m++) {
if ((XGI21_LCDCapList[m].LVDSHDE == XGIbios_mode[xgifb_mode_idx].xres) &&
(XGI21_LCDCapList[m].LVDSVDE == XGIbios_mode[xgifb_mode_idx].yres)) {
xgifb_reg_set(XGI_Pr.P3d4, 0x36, m);
}
}
}
} else if ((CR38&0xE0) == 0x60) { } else if ((CR38&0xE0) == 0x60) {
xgi_video_info.hasVB = HASVB_CHRONTEL; xgi_video_info.hasVB = HASVB_CHRONTEL;
} else { } else {
...@@ -2334,6 +2328,19 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, ...@@ -2334,6 +2328,19 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
} }
} }
if (xgi21_drvlcdcaplist) {
int m;
for (m = 0; m < ARRAY_SIZE(XGI21_LCDCapList); m++)
if ((XGI21_LCDCapList[m].LVDSHDE ==
XGIbios_mode[xgifb_mode_idx].xres) &&
(XGI21_LCDCapList[m].LVDSVDE ==
XGIbios_mode[xgifb_mode_idx].yres)) {
xgifb_reg_set(XGI_Pr.P3d4, 0x36, m);
break;
}
}
XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no; XGIfb_mode_no = XGIbios_mode[xgifb_mode_idx].mode_no;
/* yilin set default refresh rate */ /* yilin set default refresh rate */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment