aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-12-08 05:40:17 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:29:05 -0500
commitfd717689f46436fc212882ddc6e02a20be920634 (patch)
tree4b4a7bd76f23716fbd14886cfdfb9aab7033b2f8 /drivers
parent945f0ee257b4f91498b4061dc89b8a68c423ea6f (diff)
[PATCH] atyfb, rivafb: minor fixes
aty128fb: return an error in the unlikely event that we cannot calculate some key PLL info rivafb: * call CalcStateExt() directly, rather than via function pointers, since CalcStateExt() is the only value ever assigned to ->CalcStateExt(). * propagate error return back from CalcVClock() through callers Signed-off-by: Jeff Garzik <jeff@garzik.org> Cc: "Antonino A. Daplas" <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/aty/aty128fb.c5
-rw-r--r--drivers/video/riva/fbdev.c22
-rw-r--r--drivers/video/riva/riva_hw.c10
-rw-r--r--drivers/video/riva/riva_hw.h17
4 files changed, 43 insertions, 11 deletions
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index 276a21530b95..3feddf89d100 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -1333,6 +1333,8 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
1333 if (vclk * 12 < c.ppll_min) 1333 if (vclk * 12 < c.ppll_min)
1334 vclk = c.ppll_min/12; 1334 vclk = c.ppll_min/12;
1335 1335
1336 pll->post_divider = -1;
1337
1336 /* now, find an acceptable divider */ 1338 /* now, find an acceptable divider */
1337 for (i = 0; i < sizeof(post_dividers); i++) { 1339 for (i = 0; i < sizeof(post_dividers); i++) {
1338 output_freq = post_dividers[i] * vclk; 1340 output_freq = post_dividers[i] * vclk;
@@ -1342,6 +1344,9 @@ static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
1342 } 1344 }
1343 } 1345 }
1344 1346
1347 if (pll->post_divider < 0)
1348 return -EINVAL;
1349
1345 /* calculate feedback divider */ 1350 /* calculate feedback divider */
1346 n = c.ref_divider * output_freq; 1351 n = c.ref_divider * output_freq;
1347 d = c.ref_clk; 1352 d = c.ref_clk;
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
index c6f86859399c..345e8b1c1af8 100644
--- a/drivers/video/riva/fbdev.c
+++ b/drivers/video/riva/fbdev.c
@@ -740,11 +740,12 @@ static void riva_load_state(struct riva_par *par, struct riva_regs *regs)
740 * CALLED FROM: 740 * CALLED FROM:
741 * rivafb_set_par() 741 * rivafb_set_par()
742 */ 742 */
743static void riva_load_video_mode(struct fb_info *info) 743static int riva_load_video_mode(struct fb_info *info)
744{ 744{
745 int bpp, width, hDisplaySize, hDisplay, hStart, 745 int bpp, width, hDisplaySize, hDisplay, hStart,
746 hEnd, hTotal, height, vDisplay, vStart, vEnd, vTotal, dotClock; 746 hEnd, hTotal, height, vDisplay, vStart, vEnd, vTotal, dotClock;
747 int hBlankStart, hBlankEnd, vBlankStart, vBlankEnd; 747 int hBlankStart, hBlankEnd, vBlankStart, vBlankEnd;
748 int rc;
748 struct riva_par *par = info->par; 749 struct riva_par *par = info->par;
749 struct riva_regs newmode; 750 struct riva_regs newmode;
750 751
@@ -850,8 +851,10 @@ static void riva_load_video_mode(struct fb_info *info)
850 else 851 else
851 newmode.misc_output |= 0x80; 852 newmode.misc_output |= 0x80;
852 853
853 par->riva.CalcStateExt(&par->riva, &newmode.ext, bpp, width, 854 rc = CalcStateExt(&par->riva, &newmode.ext, bpp, width,
854 hDisplaySize, height, dotClock); 855 hDisplaySize, height, dotClock);
856 if (rc)
857 goto out;
855 858
856 newmode.ext.scale = NV_RD32(par->riva.PRAMDAC, 0x00000848) & 859 newmode.ext.scale = NV_RD32(par->riva.PRAMDAC, 0x00000848) &
857 0xfff000ff; 860 0xfff000ff;
@@ -883,8 +886,12 @@ static void riva_load_video_mode(struct fb_info *info)
883 par->current_state = newmode; 886 par->current_state = newmode;
884 riva_load_state(par, &par->current_state); 887 riva_load_state(par, &par->current_state);
885 par->riva.LockUnlock(&par->riva, 0); /* important for HW cursor */ 888 par->riva.LockUnlock(&par->riva, 0); /* important for HW cursor */
889
890out:
886 rivafb_blank(FB_BLANK_UNBLANK, info); 891 rivafb_blank(FB_BLANK_UNBLANK, info);
887 NVTRACE_LEAVE(); 892 NVTRACE_LEAVE();
893
894 return rc;
888} 895}
889 896
890static void riva_update_var(struct fb_var_screeninfo *var, struct fb_videomode *modedb) 897static void riva_update_var(struct fb_var_screeninfo *var, struct fb_videomode *modedb)
@@ -1252,12 +1259,15 @@ static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
1252static int rivafb_set_par(struct fb_info *info) 1259static int rivafb_set_par(struct fb_info *info)
1253{ 1260{
1254 struct riva_par *par = info->par; 1261 struct riva_par *par = info->par;
1262 int rc = 0;
1255 1263
1256 NVTRACE_ENTER(); 1264 NVTRACE_ENTER();
1257 /* vgaHWunlock() + riva unlock (0x7F) */ 1265 /* vgaHWunlock() + riva unlock (0x7F) */
1258 CRTCout(par, 0x11, 0xFF); 1266 CRTCout(par, 0x11, 0xFF);
1259 par->riva.LockUnlock(&par->riva, 0); 1267 par->riva.LockUnlock(&par->riva, 0);
1260 riva_load_video_mode(info); 1268 rc = riva_load_video_mode(info);
1269 if (rc)
1270 goto out;
1261 if(!(info->flags & FBINFO_HWACCEL_DISABLED)) 1271 if(!(info->flags & FBINFO_HWACCEL_DISABLED))
1262 riva_setup_accel(info); 1272 riva_setup_accel(info);
1263 1273
@@ -1270,8 +1280,10 @@ static int rivafb_set_par(struct fb_info *info)
1270 info->pixmap.scan_align = 1; 1280 info->pixmap.scan_align = 1;
1271 else 1281 else
1272 info->pixmap.scan_align = 4; 1282 info->pixmap.scan_align = 4;
1283
1284out:
1273 NVTRACE_LEAVE(); 1285 NVTRACE_LEAVE();
1274 return 0; 1286 return rc;
1275} 1287}
1276 1288
1277/** 1289/**
diff --git a/drivers/video/riva/riva_hw.c b/drivers/video/riva/riva_hw.c
index b6f8690b96c9..e0b8c521cc9c 100644
--- a/drivers/video/riva/riva_hw.c
+++ b/drivers/video/riva/riva_hw.c
@@ -1227,7 +1227,7 @@ static int CalcVClock
1227 * Calculate extended mode parameters (SVGA) and save in a 1227 * Calculate extended mode parameters (SVGA) and save in a
1228 * mode state structure. 1228 * mode state structure.
1229 */ 1229 */
1230static void CalcStateExt 1230int CalcStateExt
1231( 1231(
1232 RIVA_HW_INST *chip, 1232 RIVA_HW_INST *chip,
1233 RIVA_HW_STATE *state, 1233 RIVA_HW_STATE *state,
@@ -1249,7 +1249,8 @@ static void CalcStateExt
1249 * Extended RIVA registers. 1249 * Extended RIVA registers.
1250 */ 1250 */
1251 pixelDepth = (bpp + 1)/8; 1251 pixelDepth = (bpp + 1)/8;
1252 CalcVClock(dotClock, &VClk, &m, &n, &p, chip); 1252 if (!CalcVClock(dotClock, &VClk, &m, &n, &p, chip))
1253 return -EINVAL;
1253 1254
1254 switch (chip->Architecture) 1255 switch (chip->Architecture)
1255 { 1256 {
@@ -1327,6 +1328,8 @@ static void CalcStateExt
1327 state->pitch1 = 1328 state->pitch1 =
1328 state->pitch2 = 1329 state->pitch2 =
1329 state->pitch3 = pixelDepth * width; 1330 state->pitch3 = pixelDepth * width;
1331
1332 return 0;
1330} 1333}
1331/* 1334/*
1332 * Load fixed function state and pre-calculated/stored state. 1335 * Load fixed function state and pre-calculated/stored state.
@@ -2026,7 +2029,6 @@ static void nv3GetConfig
2026 */ 2029 */
2027 chip->Busy = nv3Busy; 2030 chip->Busy = nv3Busy;
2028 chip->ShowHideCursor = ShowHideCursor; 2031 chip->ShowHideCursor = ShowHideCursor;
2029 chip->CalcStateExt = CalcStateExt;
2030 chip->LoadStateExt = LoadStateExt; 2032 chip->LoadStateExt = LoadStateExt;
2031 chip->UnloadStateExt = UnloadStateExt; 2033 chip->UnloadStateExt = UnloadStateExt;
2032 chip->SetStartAddress = SetStartAddress3; 2034 chip->SetStartAddress = SetStartAddress3;
@@ -2084,7 +2086,6 @@ static void nv4GetConfig
2084 */ 2086 */
2085 chip->Busy = nv4Busy; 2087 chip->Busy = nv4Busy;
2086 chip->ShowHideCursor = ShowHideCursor; 2088 chip->ShowHideCursor = ShowHideCursor;
2087 chip->CalcStateExt = CalcStateExt;
2088 chip->LoadStateExt = LoadStateExt; 2089 chip->LoadStateExt = LoadStateExt;
2089 chip->UnloadStateExt = UnloadStateExt; 2090 chip->UnloadStateExt = UnloadStateExt;
2090 chip->SetStartAddress = SetStartAddress; 2091 chip->SetStartAddress = SetStartAddress;
@@ -2186,7 +2187,6 @@ static void nv10GetConfig
2186 */ 2187 */
2187 chip->Busy = nv10Busy; 2188 chip->Busy = nv10Busy;
2188 chip->ShowHideCursor = ShowHideCursor; 2189 chip->ShowHideCursor = ShowHideCursor;
2189 chip->CalcStateExt = CalcStateExt;
2190 chip->LoadStateExt = LoadStateExt; 2190 chip->LoadStateExt = LoadStateExt;
2191 chip->UnloadStateExt = UnloadStateExt; 2191 chip->UnloadStateExt = UnloadStateExt;
2192 chip->SetStartAddress = SetStartAddress; 2192 chip->SetStartAddress = SetStartAddress;
diff --git a/drivers/video/riva/riva_hw.h b/drivers/video/riva/riva_hw.h
index a1e71a626df2..c2769f73e0b2 100644
--- a/drivers/video/riva/riva_hw.h
+++ b/drivers/video/riva/riva_hw.h
@@ -463,7 +463,6 @@ typedef struct _riva_hw_inst
463 * Common chip functions. 463 * Common chip functions.
464 */ 464 */
465 int (*Busy)(struct _riva_hw_inst *); 465 int (*Busy)(struct _riva_hw_inst *);
466 void (*CalcStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *,int,int,int,int,int);
467 void (*LoadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *); 466 void (*LoadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
468 void (*UnloadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *); 467 void (*UnloadStateExt)(struct _riva_hw_inst *,struct _riva_hw_state *);
469 void (*SetStartAddress)(struct _riva_hw_inst *,U032); 468 void (*SetStartAddress)(struct _riva_hw_inst *,U032);
@@ -528,6 +527,22 @@ typedef struct _riva_hw_state
528 U032 pitch2; 527 U032 pitch2;
529 U032 pitch3; 528 U032 pitch3;
530} RIVA_HW_STATE; 529} RIVA_HW_STATE;
530
531/*
532 * function prototypes
533 */
534
535extern int CalcStateExt
536(
537 RIVA_HW_INST *chip,
538 RIVA_HW_STATE *state,
539 int bpp,
540 int width,
541 int hDisplaySize,
542 int height,
543 int dotClock
544);
545
531/* 546/*
532 * External routines. 547 * External routines.
533 */ 548 */