Wed Jul 2 11:54:48 2014 UTC ()
detect and (attempt to) deal with 8bit TCX with 2MB VRAM
TODO: get one of these VRAM modules...


(macallan)
diff -r1.5 -r1.6 xsrc/external/mit/xf86-video-suntcx/dist/src/tcx.h
diff -r1.7 -r1.8 xsrc/external/mit/xf86-video-suntcx/dist/src/tcx_accel.c
diff -r1.7 -r1.8 xsrc/external/mit/xf86-video-suntcx/dist/src/tcx_driver.c

cvs diff -r1.5 -r1.6 xsrc/external/mit/xf86-video-suntcx/dist/src/tcx.h (expand / switch to unified diff)

--- xsrc/external/mit/xf86-video-suntcx/dist/src/tcx.h 2014/06/18 16:55:28 1.5
+++ xsrc/external/mit/xf86-video-suntcx/dist/src/tcx.h 2014/07/02 11:54:48 1.6
@@ -49,26 +49,27 @@ @@ -49,26 +49,27 @@
49#define TCX_ALT_VOFF 0x7000a000 49#define TCX_ALT_VOFF 0x7000a000
50#define TCX_SYNC_VOFF 0x7000e000 50#define TCX_SYNC_VOFF 0x7000e000
51 51
52typedef struct { 52typedef struct {
53 unsigned char *fb; 53 unsigned char *fb;
54 int width; 54 int width;
55 int height; 55 int height;
56 unsigned int *cplane; 56 unsigned int *cplane;
57 TcxThcPtr thc; 57 TcxThcPtr thc;
58 sbusDevicePtr psdp; 58 sbusDevicePtr psdp;
59 CloseScreenProcPtr CloseScreen; 59 CloseScreenProcPtr CloseScreen;
60 Bool HWCursor; 60 Bool HWCursor;
61 Bool Is8bit; 61 Bool Is8bit;
 62 int vramsize; /* size of the 8bit fb */
62 uint64_t *rblit; 63 uint64_t *rblit;
63 uint64_t *rstip; 64 uint64_t *rstip;
64 xf86CursorInfoPtr CursorInfoRec; 65 xf86CursorInfoPtr CursorInfoRec;
65 unsigned int CursorXY; 66 unsigned int CursorXY;
66 int CursorBg, CursorFg; 67 int CursorBg, CursorFg;
67 Bool CursorEnabled, NoAccel; 68 Bool CursorEnabled, NoAccel;
68 unsigned char CursorShiftX, CursorShiftY; 69 unsigned char CursorShiftX, CursorShiftY;
69 unsigned char *CursorData; 70 unsigned char *CursorData;
70 OptionInfoPtr Options; 71 OptionInfoPtr Options;
71 ExaDriverPtr pExa; 72 ExaDriverPtr pExa;
72 int xdir, ydir, srcoff, srcpitch, fg, pitchshift; 73 int xdir, ydir, srcoff, srcpitch, fg, pitchshift;
73} TcxRec, *TcxPtr; 74} TcxRec, *TcxPtr;
74 75

cvs diff -r1.7 -r1.8 xsrc/external/mit/xf86-video-suntcx/dist/src/tcx_accel.c (expand / switch to unified diff)

--- xsrc/external/mit/xf86-video-suntcx/dist/src/tcx_accel.c 2013/06/04 22:58:31 1.7
+++ xsrc/external/mit/xf86-video-suntcx/dist/src/tcx_accel.c 2014/07/02 11:54:48 1.8
@@ -11,27 +11,27 @@ @@ -11,27 +11,27 @@
11 * furnished to do so, subject to the following conditions: 11 * furnished to do so, subject to the following conditions:
12 * 12 *
13 * The above copyright notice and this permission notice shall be included in 13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software. 14 * all copies or substantial portions of the Software.
15 * 15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */ 22 */
23 23
24/* $NetBSD: tcx_accel.c,v 1.7 2013/06/04 22:58:31 mrg Exp $ */ 24/* $NetBSD: tcx_accel.c,v 1.8 2014/07/02 11:54:48 macallan Exp $ */
25 25
26#include <sys/types.h> 26#include <sys/types.h>
27 27
28#include "tcx.h" 28#include "tcx.h"
29 29
30#ifdef DEBUG 30#ifdef DEBUG
31#define ENTER xf86Msg(X_ERROR, "%s\n", __func__) 31#define ENTER xf86Msg(X_ERROR, "%s\n", __func__)
32#define LEAVE xf86Msg(X_ERROR, "%s done\n", __func__) 32#define LEAVE xf86Msg(X_ERROR, "%s done\n", __func__)
33#else 33#else
34#define ENTER 34#define ENTER
35#define LEAVE 35#define LEAVE
36#endif 36#endif
37 37
@@ -331,33 +331,33 @@ TcxInitAccel(ScreenPtr pScreen) @@ -331,33 +331,33 @@ TcxInitAccel(ScreenPtr pScreen)
331 ExaDriverPtr pExa; 331 ExaDriverPtr pExa;
332 332
333 pExa = exaDriverAlloc(); 333 pExa = exaDriverAlloc();
334 if (!pExa) 334 if (!pExa)
335 return FALSE; 335 return FALSE;
336 336
337 pTcx->pExa = pExa; 337 pTcx->pExa = pExa;
338 338
339 pExa->exa_major = EXA_VERSION_MAJOR; 339 pExa->exa_major = EXA_VERSION_MAJOR;
340 pExa->exa_minor = EXA_VERSION_MINOR; 340 pExa->exa_minor = EXA_VERSION_MINOR;
341 341
342 /* 342 /*
343 * The S24 can display both 8 and 24bit data at the same time, and in 343 * The S24 can display both 8 and 24bit data at the same time, and in
344 * 24bit we can choose between gamma corrected ad direct. No idea how that 344 * 24bit we can choose between gamma corrected and direct. No idea how that
345 * would map to EXA - we'd have to pick the right framebuffer to draw into 345 * would map to EXA - we'd have to pick the right framebuffer to draw into
346 * and Solid() would need to know what kind of pixels to write 346 * and Solid() would need to know what kind of pixels to write
347 */ 347 */
348 pExa->memoryBase = pTcx->fb; 348 pExa->memoryBase = pTcx->fb;
349 if (pScrn->depth == 8) { 349 if (pScrn->depth == 8) {
350 pExa->memorySize = 1024 * 1024; 350 pExa->memorySize = pTcx->vramsize;
351 pExa->offScreenBase = pTcx->psdp->width * pTcx->psdp->height; 351 pExa->offScreenBase = pTcx->psdp->width * pTcx->psdp->height;
352 pExa->pixmapOffsetAlign = 1; 352 pExa->pixmapOffsetAlign = 1;
353 pExa->pixmapPitchAlign = 1; 353 pExa->pixmapPitchAlign = 1;
354 } else { 354 } else {
355 pExa->memorySize = 1024 * 1024 * 4; 355 pExa->memorySize = 1024 * 1024 * 4;
356 pExa->offScreenBase = pTcx->psdp->width * pTcx->psdp->height * 4; 356 pExa->offScreenBase = pTcx->psdp->width * pTcx->psdp->height * 4;
357 pExa->pixmapOffsetAlign = 4; 357 pExa->pixmapOffsetAlign = 4;
358 pExa->pixmapPitchAlign = 4; 358 pExa->pixmapPitchAlign = 4;
359 } 359 }
360 360
361 pExa->flags = EXA_OFFSCREEN_PIXMAPS; 361 pExa->flags = EXA_OFFSCREEN_PIXMAPS;
362 362
363 pExa->maxX = 2048; 363 pExa->maxX = 2048;

cvs diff -r1.7 -r1.8 xsrc/external/mit/xf86-video-suntcx/dist/src/tcx_driver.c (expand / switch to unified diff)

--- xsrc/external/mit/xf86-video-suntcx/dist/src/tcx_driver.c 2014/06/18 16:55:28 1.7
+++ xsrc/external/mit/xf86-video-suntcx/dist/src/tcx_driver.c 2014/07/02 11:54:48 1.8
@@ -282,27 +282,27 @@ TCXProbe(DriverPtr drv, int flags) @@ -282,27 +282,27 @@ TCXProbe(DriverPtr drv, int flags)
282 free(pEnt); 282 free(pEnt);
283 } 283 }
284 free(usedChips); 284 free(usedChips);
285 return foundScreen; 285 return foundScreen;
286} 286}
287 287
288/* Mandatory */ 288/* Mandatory */
289static Bool 289static Bool
290TCXPreInit(ScrnInfoPtr pScrn, int flags) 290TCXPreInit(ScrnInfoPtr pScrn, int flags)
291{ 291{
292 TcxPtr pTcx; 292 TcxPtr pTcx;
293 sbusDevicePtr psdp = NULL; 293 sbusDevicePtr psdp = NULL;
294 MessageType from; 294 MessageType from;
295 int i; 295 int i, prom;
296 int hwCursor, lowDepth; 296 int hwCursor, lowDepth;
297 297
298 if (flags & PROBE_DETECT) return FALSE; 298 if (flags & PROBE_DETECT) return FALSE;
299 299
300 /* 300 /*
301 * Note: This function is only called once at server startup, and 301 * Note: This function is only called once at server startup, and
302 * not at the start of each server generation. This means that 302 * not at the start of each server generation. This means that
303 * only things that are persistent across server generations can 303 * only things that are persistent across server generations can
304 * be initialised here. xf86Screens[] is (pScrn is a pointer to one 304 * be initialised here. xf86Screens[] is (pScrn is a pointer to one
305 * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()  305 * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()
306 * are too, and should be used for data that must persist across 306 * are too, and should be used for data that must persist across
307 * server generations. 307 * server generations.
308 * 308 *
@@ -331,38 +331,54 @@ TCXPreInit(ScrnInfoPtr pScrn, int flags) @@ -331,38 +331,54 @@ TCXPreInit(ScrnInfoPtr pScrn, int flags)
331 psdp = xf86GetSbusInfoForEntity(pEnt->index); 331 psdp = xf86GetSbusInfoForEntity(pEnt->index);
332 pTcx->psdp = psdp; 332 pTcx->psdp = psdp;
333 } else 333 } else
334 return FALSE; 334 return FALSE;
335 } 335 }
336 if (psdp == NULL) 336 if (psdp == NULL)
337 return FALSE; 337 return FALSE;
338 338
339 /********************** 339 /**********************
340 check card capabilities 340 check card capabilities
341 **********************/ 341 **********************/
342 hwCursor = 0; 342 hwCursor = 0;
343 lowDepth = 1; 343 lowDepth = 1;
344 if (sparcPromInit() >= 0) { 344
345 hwCursor = sparcPromGetBool(&psdp->node, "hw-cursor"); 345 prom = sparcPromInit();
346 lowDepth = sparcPromGetBool(&psdp->node, "tcx-8-bit"); 346 hwCursor = sparcPromGetBool(&psdp->node, "hw-cursor");
347 sparcPromClose(); 347 lowDepth = sparcPromGetBool(&psdp->node, "tcx-8-bit");
348 } 
349 348
350 pTcx->Is8bit = (lowDepth != 0);  349 pTcx->Is8bit = (lowDepth != 0);
351 /* all S24 support a hardware cursor */ 350 /* all S24 support a hardware cursor */
352 if (!lowDepth) 351 if (!lowDepth) {
353 hwCursor = 1; 352 hwCursor = 1;
 353 pTcx->vramsize = 0x100000; /* size of the 8bit fb */
 354 } else {
 355 char *b;
 356 int len = 4, v = 0;
 357
 358 /* see if we have more than 1MB vram */
 359 pTcx->vramsize = 0x100000;
 360 if ((b = sparcPromGetProperty(&psdp->node, "vram", &len)) != NULL) {
 361 memcpy(&v, b, 4);
 362 if ((v > 0) && (v < 3))
 363 pTcx->vramsize = 0x100000 * v;
 364 }
 365 xf86Msg(X_ERROR, "found %d MB video memory\n", v);
 366
 367 }
 368 if (prom)
 369 sparcPromClose();
354 370
355 xf86Msg(X_ERROR, "hw-cursor: %d\n", hwCursor); 371 xf86Msg(X_ERROR, "hw-cursor: %d\n", hwCursor);
356 372
357 /********************* 373 /*********************
358 deal with depth 374 deal with depth
359 *********************/ 375 *********************/
360  376
361 if (!xf86SetDepthBpp(pScrn, lowDepth ? 8 : 0, 0, 0, 377 if (!xf86SetDepthBpp(pScrn, lowDepth ? 8 : 0, 0, 0,
362 lowDepth ? NoDepth24Support : Support32bppFb)) { 378 lowDepth ? NoDepth24Support : Support32bppFb)) {
363 return FALSE; 379 return FALSE;
364 } else { 380 } else {
365 /* Check that the returned depth is one we support */ 381 /* Check that the returned depth is one we support */
366 switch (pScrn->depth) { 382 switch (pScrn->depth) {
367 case 8: 383 case 8:
368 /* OK */ 384 /* OK */
@@ -498,51 +514,51 @@ TCXScreenInit(SCREEN_INIT_ARGS_DECL) @@ -498,51 +514,51 @@ TCXScreenInit(SCREEN_INIT_ARGS_DECL)
498 VisualPtr visual; 514 VisualPtr visual;
499 int ret; 515 int ret;
500 516
501 /*  517 /*
502 * First get the ScrnInfoRec 518 * First get the ScrnInfoRec
503 */ 519 */
504 pScrn = xf86ScreenToScrn(pScreen); 520 pScrn = xf86ScreenToScrn(pScreen);
505 521
506 pTcx = GET_TCX_FROM_SCRN(pScrn); 522 pTcx = GET_TCX_FROM_SCRN(pScrn);
507 523
508 /* Map the TCX memory */ 524 /* Map the TCX memory */
509 if (pScrn->depth == 8) { 525 if (pScrn->depth == 8) {
510 pTcx->fb = 526 pTcx->fb =
511 xf86MapSbusMem (pTcx->psdp, TCX_RAM8_VOFF, 1024 * 1024); 527 xf86MapSbusMem (pTcx->psdp, TCX_RAM8_VOFF, pTcx->vramsize);
512 pTcx->pitchshift = 0; 528 pTcx->pitchshift = 0;
513 } else { 529 } else {
514 pTcx->fb = 530 pTcx->fb =
515 xf86MapSbusMem (pTcx->psdp, TCX_RAM24_VOFF, 1024 * 1024 * 4); 531 xf86MapSbusMem (pTcx->psdp, TCX_RAM24_VOFF, 1024 * 1024 * 4);
516 pTcx->cplane = 532 pTcx->cplane =
517 xf86MapSbusMem (pTcx->psdp, TCX_CPLANE_VOFF, 1024 * 1024 * 4); 533 xf86MapSbusMem (pTcx->psdp, TCX_CPLANE_VOFF, 1024 * 1024 * 4);
518 pTcx->pitchshift = 2; 534 pTcx->pitchshift = 2;
519 if (! pTcx->cplane) 535 if (! pTcx->cplane)
520 return FALSE; 536 return FALSE;
521 } 537 }
522 if (pTcx->HWCursor == TRUE) { 538 if (pTcx->HWCursor == TRUE) {
523 pTcx->thc = xf86MapSbusMem (pTcx->psdp, TCX_THC_VOFF, 8192); 539 pTcx->thc = xf86MapSbusMem (pTcx->psdp, TCX_THC_VOFF, 8192);
524 if (! pTcx->thc) 540 if (! pTcx->thc)
525 return FALSE; 541 return FALSE;
526 } 542 }
527 543
528 if (pTcx->Is8bit) { 544 if (pTcx->Is8bit) {
529 /* use STIP and BLIT on tcx */ 545 /* use STIP and BLIT on tcx */
530 pTcx->rblit = xf86MapSbusMem(pTcx->psdp, TCX_BLIT_VOFF, 8 * 1024 * 1024); 546 pTcx->rblit = xf86MapSbusMem(pTcx->psdp, TCX_BLIT_VOFF, 8 * pTcx->vramsize);
531 if (pTcx->rblit == NULL) { 547 if (pTcx->rblit == NULL) {
532 xf86Msg(X_ERROR, "Couldn't map BLIT space\n"); 548 xf86Msg(X_ERROR, "Couldn't map BLIT space\n");
533 return FALSE; 549 return FALSE;
534 } 550 }
535 pTcx->rstip = xf86MapSbusMem(pTcx->psdp, TCX_STIP_VOFF, 8 * 1024 * 1024); 551 pTcx->rstip = xf86MapSbusMem(pTcx->psdp, TCX_STIP_VOFF, 8 * pTcx->vramsize);
536 if (pTcx->rstip == NULL) { 552 if (pTcx->rstip == NULL) {
537 xf86Msg(X_ERROR, "Couldn't map STIP space\n"); 553 xf86Msg(X_ERROR, "Couldn't map STIP space\n");
538 return FALSE; 554 return FALSE;
539 } 555 }
540 } else { 556 } else {
541 /* use RSTIP and RBLIT on S24 */ 557 /* use RSTIP and RBLIT on S24 */
542 pTcx->rblit = xf86MapSbusMem(pTcx->psdp, TCX_RBLIT_VOFF, 8 * 1024 * 1024); 558 pTcx->rblit = xf86MapSbusMem(pTcx->psdp, TCX_RBLIT_VOFF, 8 * 1024 * 1024);
543 if (pTcx->rblit == NULL) { 559 if (pTcx->rblit == NULL) {
544 xf86Msg(X_ERROR, "Couldn't map RBLIT space\n"); 560 xf86Msg(X_ERROR, "Couldn't map RBLIT space\n");
545 return FALSE; 561 return FALSE;
546 } 562 }
547 pTcx->rstip = xf86MapSbusMem(pTcx->psdp, TCX_RSTIP_VOFF, 8 * 1024 * 1024); 563 pTcx->rstip = xf86MapSbusMem(pTcx->psdp, TCX_RSTIP_VOFF, 8 * 1024 * 1024);
548 if (pTcx->rstip == NULL) { 564 if (pTcx->rstip == NULL) {