mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

438 lines
15 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/x11/xfree86/mga-ppc-rs6k.patch
  9. # ROCK Linux is Copyright (C) 1998 - 2004 Clifford Wolf
  10. #
  11. # This patch file is dual-licensed. It is available under the license the
  12. # patched project is licensed under, as long as it is an OpenSource license
  13. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  14. # of the GNU General Public License as published by the Free Software
  15. # Foundation; either version 2 of the License, or (at your option) any later
  16. # version.
  17. #
  18. # --- ROCK-COPYRIGHT-NOTE-END ---
  19. This patch fixes various tiny but accumulating issues in the mga
  20. driver for big-endian machines - e.g. debugged and tested on PowerPC /
  21. RS/6k:
  22. - use of the correct PCI config space register to get the MMIO range
  23. - disable byte-swapping the framebuffer for a little-endian FB
  24. - use a tinier probe size for g200 video-ram (the g200 seems to wrap
  25. every 8MB boundary - at least here as configured in my RS/6k) and
  26. harden the memory-access loop a bit
  27. - fix the XVideo MGACopyMangled for big-endian (...)
  28. - added some stray "ScrnInfoPtr pScrn" for compilation with DEBUG
  29. defined
  30. - fixed the debugging macros (for big-endian) and improved them a bit
  31. to make debugging for people without the SPEC or long experience with
  32. the driver easier
  33. diff -ur xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga.h
  34. --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h 2003-10-10 13:06:02.000000000 +0200
  35. +++ xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga.h 2004-02-15 00:51:40.000000000 +0100
  36. @@ -91,7 +91,7 @@
  37. } MGAOpts;
  38. -#if !defined(EXTRADEBUG)
  39. +#if EXTRADEBUG != 1
  40. #define INREG8(addr) MMIO_IN8(pMga->IOBase, addr)
  41. #define INREG16(addr) MMIO_IN16(pMga->IOBase, addr)
  42. #define INREG(addr) MMIO_IN32(pMga->IOBase, addr)
  43. @@ -99,18 +99,18 @@
  44. #define OUTREG16(addr, val) MMIO_OUT16(pMga->IOBase, addr, val)
  45. #define OUTREG(addr, val) MMIO_OUT32(pMga->IOBase, addr, val)
  46. #else /* !EXTRADEBUG */
  47. -CARD8 dbg_inreg8(ScrnInfoPtr,int,int);
  48. -CARD16 dbg_inreg16(ScrnInfoPtr,int,int);
  49. -CARD32 dbg_inreg32(ScrnInfoPtr,int,int);
  50. -void dbg_outreg8(ScrnInfoPtr,int,int);
  51. -void dbg_outreg16(ScrnInfoPtr,int,int);
  52. -void dbg_outreg32(ScrnInfoPtr,int,int);
  53. -#define INREG8(addr) dbg_inreg8(pScrn,addr,1)
  54. -#define INREG16(addr) dbg_inreg16(pScrn,addr,1)
  55. -#define INREG(addr) dbg_inreg32(pScrn,addr,1)
  56. -#define OUTREG8(addr,val) dbg_outreg8(pScrn,addr,val)
  57. -#define OUTREG16(addr,val) dbg_outreg16(pScrn,addr,val)
  58. -#define OUTREG(addr,val) dbg_outreg32(pScrn,addr,val)
  59. +CARD8 dbg_inreg8(ScrnInfoPtr,int,int,char*);
  60. +CARD16 dbg_inreg16(ScrnInfoPtr,int,int,char*);
  61. +CARD32 dbg_inreg32(ScrnInfoPtr,int,int,char*);
  62. +void dbg_outreg8(ScrnInfoPtr,int,int,char*);
  63. +void dbg_outreg16(ScrnInfoPtr,int,int,char*);
  64. +void dbg_outreg32(ScrnInfoPtr,int,int,char*);
  65. +#define INREG8(addr) dbg_inreg8(pScrn,addr,1,__FUNCTION__)
  66. +#define INREG16(addr) dbg_inreg16(pScrn,addr,1,__FUNCTION__)
  67. +#define INREG(addr) dbg_inreg32(pScrn,addr,1,__FUNCTION__)
  68. +#define OUTREG8(addr,val) dbg_outreg8(pScrn,addr,val,__FUNCTION__)
  69. +#define OUTREG16(addr,val) dbg_outreg16(pScrn,addr,val,__FUNCTION__)
  70. +#define OUTREG(addr,val) dbg_outreg32(pScrn,addr,val,__FUNCTION__)
  71. #endif /* EXTRADEBUG */
  72. /*
  73. diff -ur xc/programs/Xserver/hw/xfree86/drivers/mga/mga_arc.c xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga_arc.c
  74. --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_arc.c 2003-07-25 13:04:46.000000000 +0200
  75. +++ xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga_arc.c 2004-02-13 01:18:07.000000000 +0100
  76. @@ -70,6 +70,7 @@
  77. ){
  78. int yoffset, dyoffset, x, y, a, b, d, mask, k1, k3, dx, dy, tmp;
  79. XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
  80. + ScrnInfoPtr pScrn = xf86Screens[pGC->pScreen->myNum];
  81. MGAPtr pMga = MGAPTR(infoRec->pScrn);
  82. miZeroArcRec info;
  83. Bool do360;
  84. diff -ur xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c
  85. --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c 2003-11-21 06:59:14.000000000 +0100
  86. +++ xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c 2004-02-15 01:06:51.000000000 +0100
  87. @@ -24,6 +24,8 @@
  88. #include "mga_bios.h"
  89. #include "mga_reg.h"
  90. +
  91. +#define EXTRADEBUG 0
  92. #include "mga.h"
  93. #include "mga_macros.h"
  94. @@ -548,6 +550,14 @@
  95. MGACRTC2GetPitch(pScrn, &ModeInfo);
  96. MGACRTC2GetDisplayStart(pScrn, &ModeInfo,0,0,0);
  97. }
  98. +
  99. + /* Disable byte-swapping for big-endian architectures - the XFree
  100. + driver seems to like a little-endian framebuffer -ReneR */
  101. +#if X_BYTE_ORDER == X_BIG_ENDIAN
  102. + /* pReg->Option |= 0x80000000; */
  103. + pReg->Option &= ~0x80000000;
  104. +#endif
  105. +
  106. return(TRUE);
  107. }
  108. @@ -670,6 +680,14 @@
  109. }
  110. if(!pMga->SecondCrtc) {
  111. + /* Do not set the memory config for primary cards as it
  112. + should be correct already. Only on little endian architectures
  113. + since we need to modify the byteswap bit. -ReneR */
  114. +#if X_BYTE_ORDER == X_BIG_ENDIAN
  115. + optionMask = OPTION1_MASK;
  116. +#else
  117. + optionMask = (pMga->Primary) ? OPTION1_MASK_PRIMARY : OPTION1_MASK;
  118. +#endif
  119. MGA_NOT_HAL(
  120. /*
  121. @@ -695,10 +713,6 @@
  122. outMGAdac(i, mgaReg->DacRegs[i]);
  123. }
  124. - /* Do not set the memory config for primary cards as it
  125. - should be correct already */
  126. - optionMask = (pMga->Primary) ? OPTION1_MASK_PRIMARY : OPTION1_MASK;
  127. -
  128. if (!MGAISGx50(pMga)) {
  129. /* restore pci_option register */
  130. pciSetBitsLong(pMga->PciTag, PCI_OPTION_REG, optionMask,
  131. @@ -939,6 +953,7 @@
  132. MGAPtr pMga = MGAPTR(pScrn);
  133. x += 64;
  134. y += 64;
  135. +
  136. #ifdef USEMGAHAL
  137. MGA_HAL(
  138. x += pMga->HALGranularityOffX;
  139. @@ -1033,7 +1048,8 @@
  140. static void
  141. MGAG_I2CGetBits(I2CBusPtr b, int *clock, int *data)
  142. {
  143. - MGAPtr pMga = MGAPTR(xf86Screens[b->scrnIndex]);
  144. + ScrnInfoPtr pScrn = xf86Screens[b->scrnIndex];
  145. + MGAPtr pMga = MGAPTR(pScrn);
  146. unsigned char val;
  147. /* Get the result. */
  148. @@ -1054,7 +1070,8 @@
  149. static void
  150. MGAG_I2CPutBits(I2CBusPtr b, int clock, int data)
  151. {
  152. - MGAPtr pMga = MGAPTR(xf86Screens[b->scrnIndex]);
  153. + ScrnInfoPtr pScrn = xf86Screens[b->scrnIndex];
  154. + MGAPtr pMga = MGAPTR(pScrn);
  155. unsigned char drv, val;
  156. val = (clock ? DDC_SCL_MASK : 0) | (data ? DDC_SDA_MASK : 0);
  157. diff -ur xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
  158. --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c 2003-11-21 06:59:15.000000000 +0100
  159. +++ xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c 2004-02-15 01:08:02.000000000 +0100
  160. @@ -926,7 +926,7 @@
  161. return 16384;
  162. }
  163. }
  164. - ProbeSize = 16384;
  165. + ProbeSize = 8192;
  166. break;
  167. case PCI_CHIP_MGAG100:
  168. case PCI_CHIP_MGAG100_PCI:
  169. @@ -954,11 +954,14 @@
  170. tmp = INREG8(MGAREG_CRTCEXT_DATA);
  171. OUTREG8(MGAREG_CRTCEXT_DATA, tmp | 0x80);
  172. - /* write, read and compare method */
  173. + /* write, read and compare method
  174. + split into two loops to make it more reliable on RS/6k -ReneR */
  175. for(i = ProbeSize; i > 2048; i -= 2048) {
  176. base[(i * 1024) - 1] = 0xAA;
  177. - OUTREG8(MGAREG_CRTC_INDEX, 0); /* flush the cache */
  178. - usleep(1); /* twart write combination */
  179. + }
  180. + OUTREG8(MGAREG_CRTC_INDEX, 0); /* flush the cache */
  181. + usleep(4); /* twart write combination */
  182. + for(i = ProbeSize; i > 2048; i -= 2048) {
  183. if(base[(i * 1024) - 1] == 0xAA) {
  184. SizeFound = i;
  185. break;
  186. @@ -1266,8 +1269,8 @@
  187. is handled locally and not visible outside. If the VGA fb is
  188. handeled by the same function the third argument has to be set,
  189. too.*/
  190. - xf86SetAccessFuncs(pMga->pEnt, &pMga->Access, &pMga->Access,
  191. - &pMga->Access, NULL);
  192. + /* XXX: does not compile with recent XFree API changes -ReneR */
  193. + xf86SetAccessFuncs(pMga->pEnt, &pMga->Access, &pMga->Access);
  194. #endif
  195. /* Set pScrn->monitor */
  196. @@ -1779,7 +1782,8 @@
  197. }
  198. }
  199. #else
  200. - pMga->IOAddress = pMga->PciInfo->memBase[0];
  201. + /* changed to memBase[1] - tested on PowerPC RS/6k -ReneR */
  202. + pMga->IOAddress = pMga->PciInfo->memBase[1];
  203. #endif
  204. xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at 0x%lX\n",
  205. (unsigned long)pMga->IOAddress);
  206. @@ -2506,7 +2510,6 @@
  207. pMga->FbStart = pMga->FbBase + pMga->YDstOrg * (pScrn->bitsPerPixel / 8);
  208. -
  209. /* Map the ILOAD transfer window if there is one. We only make
  210. DWORD access on DWORD boundaries to this window */
  211. if (pMga->ILOADAddress) {
  212. @@ -4065,90 +4068,82 @@
  213. */
  214. CARD8
  215. -dbg_inreg8(ScrnInfoPtr pScrn,int addr,int verbose)
  216. +dbg_inreg8(ScrnInfoPtr pScrn,int addr,int verbose, char* func)
  217. {
  218. - MGAPtr pMga;
  219. CARD8 ret;
  220. - pMga = MGAPTR(pScrn);
  221. - ret = *(volatile CARD8 *)(pMga->IOBase + (addr));
  222. + ret = MMIO_IN8(MGAPTR(pScrn)->IOBase,addr);
  223. if(verbose)
  224. xf86DrvMsg(pScrn->scrnIndex, X_INFO,
  225. - "inreg8 : 0x%8x = 0x%x\n",addr,ret);
  226. + "inreg8 : %s: 0x%8x = 0x%x\n",func, addr,ret);
  227. return ret;
  228. }
  229. CARD16
  230. -dbg_inreg16(ScrnInfoPtr pScrn,int addr,int verbose)
  231. +dbg_inreg16(ScrnInfoPtr pScrn,int addr,int verbose, char* func)
  232. {
  233. - MGAPtr pMga;
  234. CARD16 ret;
  235. - pMga = MGAPTR(pScrn);
  236. - ret = *(volatile CARD16 *)(pMga->IOBase + (addr));
  237. + ret = MMIO_IN16(MGAPTR(pScrn)->IOBase,addr);
  238. if(verbose)
  239. xf86DrvMsg(pScrn->scrnIndex, X_INFO,
  240. - "inreg16: 0x%8x = 0x%x\n",addr,ret);
  241. + "inreg16: %s: 0x%8x = 0x%x\n",func, addr,ret);
  242. return ret;
  243. }
  244. CARD32
  245. -dbg_inreg32(ScrnInfoPtr pScrn,int addr,int verbose)
  246. +dbg_inreg32(ScrnInfoPtr pScrn,int addr,int verbose, char* func)
  247. {
  248. - MGAPtr pMga;
  249. CARD32 ret;
  250. - pMga = MGAPTR(pScrn);
  251. - ret = *(volatile CARD32 *)(pMga->IOBase + (addr));
  252. + ret = MMIO_IN32(MGAPTR(pScrn)->IOBase,addr);
  253. if(verbose)
  254. xf86DrvMsg(pScrn->scrnIndex, X_INFO,
  255. - "inreg32: 0x%8x = 0x%x\n",addr,ret);
  256. + "inreg32: %s: 0x%8x = 0x%x\n",func, addr,ret);
  257. return ret;
  258. }
  259. void
  260. -dbg_outreg8(ScrnInfoPtr pScrn,int addr,int val)
  261. +dbg_outreg8(ScrnInfoPtr pScrn,int addr,int val, char* func)
  262. {
  263. - MGAPtr pMga;
  264. CARD8 ret;
  265. - pMga = MGAPTR(pScrn);
  266. #if 0
  267. if( addr = MGAREG_CRTCEXT_DATA )
  268. return;
  269. #endif
  270. if( addr != 0x3c00 ) {
  271. - ret = dbg_inreg8(pScrn,addr,0);
  272. + ret = dbg_inreg8(pScrn,addr,0,func);
  273. xf86DrvMsg(pScrn->scrnIndex, X_INFO,
  274. - "outreg8 : 0x%8x = 0x%x was 0x%x\n",addr,val,ret);
  275. + "outreg8 : %s: 0x%8x = 0x%x was 0x%x\n",
  276. + func,addr,val,ret);
  277. }
  278. else {
  279. - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "outreg8 : index 0x%x\n",val);
  280. + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "outreg8 : %s: index 0x%x\n",
  281. + func,val);
  282. }
  283. - *(volatile CARD8 *)(pMga->IOBase + (addr)) = (val);
  284. + MMIO_OUT8(MGAPTR(pScrn)->IOBase,addr,val);
  285. }
  286. void
  287. -dbg_outreg16(ScrnInfoPtr pScrn,int addr,int val)
  288. +dbg_outreg16(ScrnInfoPtr pScrn,int addr,int val, char* func)
  289. {
  290. - MGAPtr pMga;
  291. CARD16 ret;
  292. #if 0
  293. if (addr == MGAREG_CRTCEXT_INDEX)
  294. return;
  295. #endif
  296. - pMga = MGAPTR(pScrn);
  297. - ret = dbg_inreg16(pScrn,addr,0);
  298. + ret = dbg_inreg16(pScrn,addr,0, func);
  299. xf86DrvMsg(pScrn->scrnIndex, X_INFO,
  300. - "outreg16 : 0x%8x = 0x%x was 0x%x\n",addr,val,ret);
  301. - *(volatile CARD16 *)(pMga->IOBase + (addr)) = (val);
  302. + "outreg16: %s: 0x%8x = 0x%x was 0x%x\n",
  303. + func,addr,val,ret);
  304. + MMIO_OUT16(MGAPTR(pScrn)->IOBase,addr,val);
  305. }
  306. void
  307. -dbg_outreg32(ScrnInfoPtr pScrn,int addr,int val)
  308. +dbg_outreg32(ScrnInfoPtr pScrn,int addr,int val, char* func)
  309. {
  310. - MGAPtr pMga;
  311. CARD32 ret;
  312. if (((addr & 0xff00) == 0x1c00)
  313. @@ -4162,17 +4157,21 @@
  314. && (addr != 0x1c98)
  315. && (addr != 0x1c9c)
  316. ) {
  317. - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "refused address 0x%x\n",addr);
  318. + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%s: refused address 0x%x\n",
  319. + func,addr);
  320. return;
  321. }
  322. - pMga = MGAPTR(pScrn);
  323. - ret = dbg_inreg32(pScrn,addr,0);
  324. + ret = dbg_inreg32(pScrn,addr,0, func);
  325. xf86DrvMsg(pScrn->scrnIndex, X_INFO,
  326. - "outreg32 : 0x%8x = 0x%x was 0x%x\n",addr,val,ret);
  327. - *(volatile CARD32 *)(pMga->IOBase + (addr)) = (val);
  328. + "outreg32: %s: 0x%8x = 0x%x was 0x%x\n",
  329. + func,addr,val,ret);
  330. + MMIO_OUT32(MGAPTR(pScrn)->IOBase,addr,val);
  331. }
  332. #endif /* DEBUG */
  333. +/* Hack for the debug macro shortcomming -ReneR */
  334. +#define OUTREG(addr, val) MMIO_OUT32(pMga->IOBase, addr, val)
  335. +
  336. static void
  337. MGAG100BlackMagic(MGAPtr pMga)
  338. {
  339. diff -ur xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c
  340. --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c 2003-01-16 17:09:10.000000000 +0100
  341. +++ xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c 2004-02-13 01:16:52.000000000 +0100
  342. @@ -2359,6 +2359,7 @@
  343. BoxPtr pbox;
  344. MGAPtr pMga;
  345. int xorg, yorg;
  346. + ScrnInfoPtr pScrn;
  347. if(!numRects) return;
  348. @@ -2369,6 +2370,7 @@
  349. infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
  350. pMga = MGAPTR(infoRec->pScrn);
  351. + pScrn = xf86Screens[pGC->pScreen->myNum];
  352. xorg = pDraw->x;
  353. yorg = pDraw->y;
  354. diff -ur xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c
  355. --- xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c 2003-11-21 06:59:15.000000000 +0100
  356. +++ xc-working/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c 2004-02-15 01:07:28.000000000 +0100
  357. @@ -458,8 +458,10 @@
  358. int h,
  359. int w
  360. ){
  361. +
  362. w <<= 1;
  363. while(h--) {
  364. + /* XXX Maybe this one needs big-endian fixes, too? -ReneR */
  365. memcpy(dst, src, w);
  366. src += srcPitch;
  367. dst += dstPitch;
  368. @@ -489,16 +491,27 @@
  369. s1 = src1; s2 = src2; s3 = src3;
  370. i = w;
  371. while(i > 4) {
  372. +#if X_BYTE_ORDER == X_LITTLE_ENDIAN
  373. dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24);
  374. dst[1] = s1[2] | (s1[3] << 16) | (s3[1] << 8) | (s2[1] << 24);
  375. dst[2] = s1[4] | (s1[5] << 16) | (s3[2] << 8) | (s2[2] << 24);
  376. dst[3] = s1[6] | (s1[7] << 16) | (s3[3] << 8) | (s2[3] << 24);
  377. +#else
  378. + dst[0] = (s1[0] << 16) | s1[1] | (s3[0] << 24) | (s2[0] << 8);
  379. + dst[1] = (s1[2] << 16) | s1[3] | (s3[1] << 24) | (s2[1] << 8);
  380. + dst[2] = (s1[4] << 16) | s1[5] | (s3[2] << 24) | (s2[2] << 8);
  381. + dst[3] = (s1[6] << 16) | s1[7] | (s3[3] << 24) | (s2[3] << 8);
  382. +#endif
  383. dst += 4; s2 += 4; s3 += 4; s1 += 8;
  384. i -= 4;
  385. }
  386. while(i--) {
  387. +#if X_BYTE_ORDER == X_LITTLE_ENDIAN
  388. dst[0] = s1[0] | (s1[1] << 16) | (s3[0] << 8) | (s2[0] << 24);
  389. +#else
  390. + dst[0] = (s1[0] << 16) | s1[1] | (s3[0] << 24) | (s2[0] << 8);
  391. +#endif
  392. dst++; s2++; s3++;
  393. s1 += 2;
  394. }
  395. @@ -1006,6 +1019,7 @@
  396. XF86SurfacePtr surface
  397. ){
  398. OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr;
  399. + ScrnInfoPtr pScrn = surface->pScrn;
  400. if(pPriv->isOn) {
  401. MGAPtr pMga = MGAPTR(surface->pScrn);