Subversion Repositories Kolibri OS

Rev

Rev 879 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2.  
  3. int ClearPixmap(io_clear_t *io)
  4. {
  5.      u32_t ifl;
  6.      u32_t *ring, write;
  7.  
  8.      local_pixmap_t *dstpixmap;
  9.  
  10.      dstpixmap = (io->dstpix == (void*)-1) ? &scr_pixmap : io->dstpix ;
  11.  
  12.      ifl = safe_cli();
  13.  
  14. #if R300_PIO
  15.  
  16.      R5xxFIFOWait(6);
  17.  
  18.      OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  19.             RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  20.             RADEON_GMC_BRUSH_SOLID_COLOR      |
  21.             RADEON_GMC_DST_32BPP              |
  22.             RADEON_GMC_SRC_DATATYPE_COLOR     |
  23.             R5XX_GMC_CLR_CMP_CNTL_DIS         |
  24.             R5XX_GMC_WR_MSK_DIS               |
  25.             R5XX_ROP3_P
  26.            );
  27.  
  28.      OUTREG(R5XX_DP_BRUSH_FRGD_CLR, io->color);
  29.      OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
  30.      OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  31.      OUTREG(R5XX_DST_Y_X, 0);
  32.      OUTREG(R5XX_DST_WIDTH_HEIGHT,(dstpixmap->width<<16)|dstpixmap->height);
  33.  
  34. #else
  35.       BEGIN_RING();
  36.         OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4));
  37.  
  38.         OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  39.                  RADEON_GMC_BRUSH_SOLID_COLOR      |
  40.                  RADEON_GMC_DST_32BPP              |
  41.                  RADEON_GMC_SRC_DATATYPE_COLOR     |
  42.                  R5XX_GMC_CLR_CMP_CNTL_DIS         |
  43.                  R5XX_GMC_WR_MSK_DIS               |
  44.                  R5XX_ROP3_P
  45.                 );
  46.  
  47.         OUT_RING(dstpixmap->pitch_offset);
  48.         OUT_RING(io->color);
  49.         OUT_RING( 0 );
  50.         OUT_RING((dstpixmap->width<<16)|dstpixmap->height);
  51.       COMMIT_RING();
  52.  
  53. #endif
  54.  
  55.      safe_sti(ifl);
  56.  
  57.      return ERR_OK;
  58. }
  59.  
  60.  
  61. int Line(io_draw_t *draw)
  62. {
  63.      local_pixmap_t *dstpixmap;
  64.      clip_t clip;
  65.      int x0, y0, x1, y1;
  66.  
  67.      dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ;
  68.  
  69.      x0 = draw->x0;
  70.      y0 = draw->y0;
  71.  
  72.      x1 = draw->x1;
  73.      y1 = draw->y1;
  74.  
  75.      clip.xmin = 0;
  76.      clip.ymin = 0;
  77.      clip.xmax = dstpixmap->width-1;
  78.      clip.ymax = dstpixmap->height-1;
  79.  
  80.      if ( !LineClip(&clip, &x0, &y0, &x1, &y1 ))
  81.      {
  82.         u32_t efl;
  83.         u32_t *ring, write;
  84.  
  85.         efl = safe_cli();
  86.  
  87. #if R300_PIO
  88.  
  89.         R5xxFIFOWait(6);
  90.  
  91.         OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  92.                RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  93.                RADEON_GMC_BRUSH_SOLID_COLOR      |
  94.                RADEON_GMC_DST_32BPP              |
  95.                RADEON_GMC_SRC_DATATYPE_COLOR     |
  96.                R5XX_GMC_CLR_CMP_CNTL_DIS         |
  97.                R5XX_GMC_WR_MSK_DIS               |
  98.                R5XX_ROP3_P
  99.               );
  100.  
  101.         OUTREG(R5XX_DST_LINE_PATCOUNT, 0x55 << R5XX_BRES_CNTL_SHIFT);
  102.  
  103.         OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color);
  104.         OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  105.  
  106.         OUTREG(R5XX_DST_LINE_START,(y0<<16)|x0);
  107.         OUTREG(R5XX_DST_LINE_END,(y1<<16)|x1);
  108. #else
  109.        BEGIN_RING();
  110.          OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_POLYLINE, 4));
  111.          OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  112.                   RADEON_GMC_BRUSH_SOLID_COLOR      |
  113.                   RADEON_GMC_DST_32BPP              |
  114.                   RADEON_GMC_SRC_DATATYPE_COLOR     |
  115.                   R5XX_GMC_CLR_CMP_CNTL_DIS         |
  116.                   R5XX_GMC_WR_MSK_DIS               |
  117.                   R5XX_ROP3_P);
  118.  
  119.          OUT_RING(dstpixmap->pitch_offset);
  120.          OUT_RING(draw->color);
  121.          OUT_RING((y0<<16)|x0);
  122.          OUT_RING((y1<<16)|x1);
  123.        COMMIT_RING();
  124.  
  125. #endif
  126.         safe_sti(efl);
  127.      };
  128.      return ERR_OK;
  129. }
  130.  
  131. int DrawRect(io_draw_t* draw)
  132. {
  133.      int x0, y0, x1, y1, xend, yend;
  134.  
  135.      local_pixmap_t *dstpixmap;
  136.      clip_t dst_clip;
  137.  
  138.      dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ;
  139.  
  140.      x0 = draw->x0;
  141.      y0 = draw->y0;
  142.  
  143.      x1 = xend = x0 + draw->w - 1;
  144.      y1 = yend = y0 + draw->h - 1;
  145.  
  146.      dst_clip.xmin = 0;
  147.      dst_clip.ymin = 0;
  148.      dst_clip.xmax = dstpixmap->width-1;
  149.      dst_clip.ymax = dstpixmap->height-1;
  150.  
  151.  
  152. //  dbgprintf("draw rect x0:%d, y0:%d, x1:%d, y1:%d, color: %x\n",
  153. //             x0, y0, x1, y1, draw->color);
  154.  
  155.      if( ! BlockClip( &dst_clip, &x0, &y0, &x1, &y1))
  156.      {
  157.         u32_t *ring, write;
  158.         u32_t ifl;
  159.         int w, h;
  160.  
  161.         w = x1 - x0 + 1;
  162.         h = y1 - y0 + 1;
  163.  
  164.         ifl = safe_cli();
  165.  
  166. #if R300_PIO
  167.  
  168.         R5xxFIFOWait(6);
  169.  
  170.         OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  171.                RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  172.                RADEON_GMC_BRUSH_SOLID_COLOR      |
  173.                RADEON_GMC_DST_32BPP              |
  174.                RADEON_GMC_SRC_DATATYPE_COLOR     |
  175.                R5XX_GMC_CLR_CMP_CNTL_DIS         |
  176.                R5XX_GMC_WR_MSK_DIS               |
  177.                R5XX_ROP3_P
  178.               );
  179.  
  180.         OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color);
  181.         OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
  182.         OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  183.         OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  184.         OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|h);
  185.  
  186.         if( draw->color != draw->border)
  187.         {
  188.            OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->border);
  189.  
  190.            if( y0 == draw->y0)
  191.            {
  192.               R5xxFIFOWait(2);
  193.  
  194.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  195.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  196.               y0++;
  197.               h--;
  198.            }
  199.            if( y1 == yend )
  200.            {
  201.               R5xxFIFOWait(2);
  202.  
  203.               OUTREG(R5XX_DST_Y_X,(y1<<16)|x0);
  204.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  205.               h--;
  206.            }
  207.            if( (h > 0) && (x0 == draw->x0))
  208.            {
  209.               R5xxFIFOWait(2);
  210.  
  211.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  212.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  213.            }
  214.            if( (h > 0) && (x1 == xend))
  215.            {
  216.               R5xxFIFOWait(2);
  217.  
  218.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x1);
  219.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  220.            }
  221.         };
  222. #else
  223.       BEGIN_RING();
  224.         OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4));
  225.  
  226.         OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  227.                  RADEON_GMC_BRUSH_SOLID_COLOR      |
  228.                  RADEON_GMC_DST_32BPP              |
  229.                  RADEON_GMC_SRC_DATATYPE_COLOR     |
  230.                  R5XX_GMC_CLR_CMP_CNTL_DIS         |
  231.                  R5XX_GMC_WR_MSK_DIS               |
  232.                  R5XX_ROP3_P
  233.                 );
  234.  
  235.         OUT_RING(dstpixmap->pitch_offset);
  236.         OUT_RING(draw->color);
  237.         OUT_RING((draw->x0<<16)|y0);
  238.         OUT_RING((w<<16)|h);
  239.       COMMIT_RING();
  240. #endif
  241.         safe_sti(ifl);
  242.      };
  243.      return ERR_OK;
  244. }
  245.  
  246. int FillRect(io_fill_t *fill)
  247. {
  248.      local_pixmap_t *dstpixmap;
  249.      clip_t dst_clip;
  250.      int x0, y0, x1, y1, xend, yend;
  251.  
  252.      dstpixmap = (fill->dstpix == (void*)-1) ? &scr_pixmap : fill->dstpix ;
  253.  
  254.      x0 = fill->x;
  255.      y0 = fill->y;
  256.  
  257.      xend = x1 = x0 + fill->w - 1;
  258.      yend = y1 = y0 + fill->h - 1;
  259.  
  260.      dst_clip.xmin = 0;
  261.      dst_clip.ymin = 0;
  262.      dst_clip.xmax = dstpixmap->width-1;
  263.      dst_clip.ymax = dstpixmap->height-1;
  264.  
  265. //  dbgprintf("fill rect x0:%d, y0:%d, x1:%d, y1:%d\n",
  266. //             x0, y0, x1, y1);
  267.  
  268.      if( ! BlockClip(&dst_clip, &x0, &y0, &x1, &y1))
  269.      {
  270.         u32_t *ring, write;
  271.         u32_t ifl = safe_cli();
  272.  
  273. #if R300_PIO
  274.  
  275.         int w = x1 - x0 + 1;
  276.         int h = y1 - y0 + 1;
  277.  
  278.         R5xxFIFOWait(9);
  279.  
  280.         OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  281.                RADEON_GMC_DST_PITCH_OFFSET_CNTL |
  282.                R5XX_GMC_BRUSH_8X8_MONO_FG_BG    |
  283.                RADEON_GMC_DST_32BPP             |
  284.                R5XX_GMC_SRC_DATATYPE_COLOR      |
  285.                R5XX_GMC_CLR_CMP_CNTL_DIS        |
  286.                R5XX_GMC_WR_MSK_DIS              |
  287.                R5XX_ROP3_P
  288.                );
  289.  
  290.         OUTREG(R5XX_DP_BRUSH_BKGD_CLR, fill->bkcolor);
  291.         OUTREG(R5XX_DP_BRUSH_FRGD_CLR, fill->fcolor);
  292.  
  293.         OUTREG(R5XX_BRUSH_DATA0, fill->bmp0);
  294.         OUTREG(R5XX_BRUSH_DATA1, fill->bmp1);
  295.  
  296.         OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
  297.         OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  298.  
  299.         OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  300.         OUTREG(R5XX_DST_HEIGHT_WIDTH,(h<<16)|w);
  301.  
  302.         if( (fill->border & 0xFF000000) != 0)
  303.         {
  304.            R5xxFIFOWait(2);
  305.  
  306.            OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  307.                   RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  308.                   RADEON_GMC_BRUSH_SOLID_COLOR      |
  309.                   RADEON_GMC_DST_32BPP              |
  310.                   RADEON_GMC_SRC_DATATYPE_COLOR     |
  311.                   R5XX_GMC_CLR_CMP_CNTL_DIS         |
  312.                   R5XX_GMC_WR_MSK_DIS               |
  313.                   R5XX_ROP3_P
  314.                  );
  315.  
  316.            OUTREG(R5XX_DP_BRUSH_FRGD_CLR, fill->border);
  317.  
  318.            if( y0 == fill->y)
  319.            {
  320.               R5xxFIFOWait(2);
  321.  
  322.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  323.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  324.               y0++;
  325.               h--;
  326.            }
  327.            if( y1 == yend )
  328.            {
  329.               R5xxFIFOWait(2);
  330.  
  331.               OUTREG(R5XX_DST_Y_X,(y1<<16)|x0);
  332.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  333.               h--;
  334.            }
  335.            if( (h > 0) && (x0 == fill->x))
  336.            {
  337.               R5xxFIFOWait(2);
  338.  
  339.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  340.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  341.            }
  342.            if( (h > 0) && (x1 == xend))
  343.            {
  344.               R5xxFIFOWait(2);
  345.  
  346.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x1);
  347.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  348.            }
  349.         };
  350.  
  351.  
  352. #else
  353.       BEGIN_RING();
  354.         OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT, 7));
  355.         OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL    |
  356.                  R5XX_GMC_BRUSH_8X8_MONO_FG_BG       |
  357.                  RADEON_GMC_DST_32BPP                |
  358.                  RADEON_GMC_SRC_DATATYPE_COLOR       |
  359.                  R5XX_GMC_CLR_CMP_CNTL_DIS           |
  360.                  R5XX_GMC_WR_MSK_DIS                 |
  361.                  R5XX_ROP3_P
  362.                 );
  363.  
  364.         OUT_RING(dstpixmap->pitch_offset);
  365.         OUT_RING(fill->bkcolor);
  366.         OUT_RING(fill->fcolor);
  367.  
  368.         OUT_RING(fill->bmp0);
  369.         OUT_RING(fill->bmp1);
  370.  
  371.         OUT_RING((y0<<16)|x0);
  372.         OUT_RING((y1<<16)|x1);
  373.       COMMIT_RING();
  374.  
  375. #endif
  376.         safe_sti(ifl);
  377.      };
  378.      return ERR_OK;
  379. };
  380.  
  381.  
  382.  
  383. int Blit(io_blit_t *blit)
  384. {
  385.      clip_t src_clip, dst_clip;
  386.  
  387.      local_pixmap_t *srcpixmap;
  388.      local_pixmap_t *dstpixmap;
  389.  
  390.      //dbgprintf("Pixblit src: %x dst: %x\n",blit->srcpix, blit->dstpix);
  391.  
  392.      dstpixmap = (blit->dstpix == (void*)-1) ? &scr_pixmap : blit->dstpix ;
  393.      srcpixmap = (blit->srcpix == (void*)-1) ? &scr_pixmap : blit->srcpix ;
  394.  
  395.      //dbgprintf("srcpixmap: %x dstpixmap: %x\n",srcpixmap, dstpixmap);
  396.  
  397.      //dbgprintf("dst.width: %d dst.height: %d\n", dstpixmap->width,dstpixmap->height);
  398.      //dbgprintf("src.width: %d src.height: %d\n", srcpixmap->width,srcpixmap->height);
  399.      //dbgprintf("srcpitch: %x dstpitch: %x\n",
  400.      //           srcpixmap->pitch_offset,dstpixmap->pitch_offset);
  401.  
  402.      src_clip.xmin = 0;
  403.      src_clip.ymin = 0;
  404.      src_clip.xmax = srcpixmap->width-1;
  405.      src_clip.ymax = srcpixmap->height-1;
  406.  
  407.      dst_clip.xmin = 0;
  408.      dst_clip.ymin = 0;
  409.      dst_clip.xmax = dstpixmap->width-1;
  410.      dst_clip.ymax = dstpixmap->height-1;
  411.  
  412.      if( !blit_clip(&dst_clip, &blit->dst_x, &blit->dst_y,
  413.                     &src_clip, &blit->src_x, &blit->src_y,
  414.                     &blit->w, &blit->h) )
  415.      {
  416.         u32_t *ring, write;
  417.  
  418.         u32_t ifl = safe_cli();
  419.  
  420. #if R300_PIO
  421.  
  422.         R5xxFIFOWait(7);
  423.  
  424.         OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  425.                RADEON_GMC_SRC_PITCH_OFFSET_CNTL  |
  426.                RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  427.                RADEON_GMC_BRUSH_NONE             |
  428.                RADEON_GMC_DST_32BPP              |
  429.                RADEON_GMC_SRC_DATATYPE_COLOR     |
  430.                RADEON_DP_SRC_SOURCE_MEMORY       |
  431.                R5XX_GMC_CLR_CMP_CNTL_DIS         |
  432.                R5XX_GMC_WR_MSK_DIS               |
  433.                R5XX_ROP3_S
  434.               );
  435.  
  436.         OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
  437.  
  438.         OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  439.         OUTREG(R5XX_SRC_PITCH_OFFSET, srcpixmap->pitch_offset);
  440.  
  441.         OUTREG(R5XX_SRC_Y_X,(blit->src_y<<16)|blit->src_x);
  442.         OUTREG(R5XX_DST_Y_X,(blit->dst_y<<16)|blit->dst_x);
  443.         OUTREG(R5XX_DST_HEIGHT_WIDTH,(blit->h<<16)|blit->w);
  444.  
  445. #else
  446.  
  447.         BEGIN_RING();
  448.           OUT_RING(CP_PACKET3(RADEON_CNTL_BITBLT, 5));
  449.  
  450.           OUT_RING(RADEON_GMC_SRC_PITCH_OFFSET_CNTL  |
  451.                    RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  452.                    RADEON_GMC_BRUSH_NONE             |
  453.                    RADEON_GMC_DST_32BPP              |
  454.                    RADEON_GMC_SRC_DATATYPE_COLOR     |
  455.                    RADEON_DP_SRC_SOURCE_MEMORY       |
  456.                    R5XX_GMC_CLR_CMP_CNTL_DIS         |
  457.                    R5XX_GMC_WR_MSK_DIS               |
  458.                    R5XX_ROP3_S
  459.                   );
  460.  
  461.           OUT_RING(srcpixmap->pitch_offset);
  462.           OUT_RING(dstpixmap->pitch_offset);
  463.  
  464.           OUT_RING((blit->src_x<<16)|blit->src_y);
  465.           OUT_RING((blit->dst_x<<16)|blit->dst_y);
  466.           OUT_RING((blit->w<<16)|blit->h);
  467.         COMMIT_RING();
  468.  
  469. #endif
  470.        safe_sti(ifl);
  471.      };
  472.      return ERR_OK;
  473. };
  474.  
  475.  
  476. int BlitTransparent(io_blit_t *blit)
  477. {
  478.      clip_t src_clip, dst_clip;
  479.  
  480.      local_pixmap_t *srcpixmap;
  481.      local_pixmap_t *dstpixmap;
  482.  
  483.     // dbgprintf("Transblit src: %x dst: %x\n",blit->srcpix, blit->dstpix);
  484.  
  485.      dstpixmap = (blit->dstpix == (void*)-1) ? &scr_pixmap : blit->dstpix ;
  486.      srcpixmap = (blit->srcpix == (void*)-1) ? &scr_pixmap : blit->srcpix ;
  487.  
  488.      //dbgprintf("srcpixmap: %x dstpixmap: %x\n",srcpixmap, dstpixmap);
  489.  
  490.      //dbgprintf("dst.width: %d dst.height: %d\n", dstpixmap->width,dstpixmap->height);
  491.      //dbgprintf("src.width: %d src.height: %d\n", srcpixmap->width,srcpixmap->height);
  492.      //dbgprintf("srcpitch: %x dstpitch: %x\n",
  493.      //           srcpixmap->pitch_offset,dstpixmap->pitch_offset);
  494.      src_clip.xmin = 0;
  495.      src_clip.ymin = 0;
  496.      src_clip.xmax = srcpixmap->width-1;
  497.      src_clip.ymax = srcpixmap->height-1;
  498.  
  499.      dst_clip.xmin = 0;
  500.      dst_clip.ymin = 0;
  501.      dst_clip.xmax = dstpixmap->width-1;
  502.      dst_clip.ymax = dstpixmap->height-1;
  503.  
  504.      if( !blit_clip(&dst_clip, &blit->dst_x, &blit->dst_y,
  505.                     &src_clip, &blit->src_x, &blit->src_y,
  506.                     &blit->w, &blit->h) )
  507.      {
  508.         u32_t *ring, write;
  509.  
  510.         u32_t ifl = safe_cli();
  511.  
  512. #if R300_PIO
  513.  
  514.         R5xxFIFOWait(10);
  515.  
  516.         OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  517.                RADEON_GMC_SRC_PITCH_OFFSET_CNTL  |
  518.                RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  519.                RADEON_GMC_BRUSH_NONE             |
  520.                RADEON_GMC_DST_32BPP              |
  521.                RADEON_GMC_SRC_DATATYPE_COLOR     |
  522.                RADEON_DP_SRC_SOURCE_MEMORY       |
  523.                R5XX_GMC_WR_MSK_DIS               |
  524.                R5XX_ROP3_S
  525.               );
  526.  
  527.         OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
  528.  
  529.         OUTREG(R5XX_CLR_CMP_CLR_SRC, 0xFF000000);
  530.         OUTREG(R5XX_CLR_CMP_MASK, R5XX_CLR_CMP_MSK);
  531.         OUTREG(R5XX_CLR_CMP_CNTL, R5XX_SRC_CMP_EQ_COLOR | R5XX_CLR_CMP_SRC_SOURCE);
  532.  
  533.         OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  534.         OUTREG(R5XX_SRC_PITCH_OFFSET, srcpixmap->pitch_offset);
  535.  
  536.         OUTREG(R5XX_SRC_Y_X,(blit->src_y<<16)|blit->src_x);
  537.         OUTREG(R5XX_DST_Y_X,(blit->dst_y<<16)|blit->dst_x);
  538.         OUTREG(R5XX_DST_HEIGHT_WIDTH,(blit->h<<16)|blit->w);
  539.  
  540. #else
  541.  
  542.         BEGIN_RING();
  543.           OUT_RING(CP_PACKET3(RADEON_CNTL_TRANBLT, 8));
  544.  
  545.           OUT_RING(RADEON_GMC_SRC_PITCH_OFFSET_CNTL  |
  546.                    RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  547.                    RADEON_GMC_BRUSH_NONE             |
  548.                    RADEON_GMC_DST_32BPP              |
  549.                    RADEON_GMC_SRC_DATATYPE_COLOR     |
  550.                    RADEON_DP_SRC_SOURCE_MEMORY       |
  551.                    R5XX_GMC_WR_MSK_DIS               |
  552.                    R5XX_ROP3_S
  553.                   );
  554.  
  555.           OUT_RING(srcpixmap->pitch_offset);
  556.           OUT_RING(dstpixmap->pitch_offset);
  557.  
  558.           OUT_RING(R5XX_CLR_CMP_SRC_SOURCE | R5XX_SRC_CMP_EQ_COLOR);
  559.           OUT_RING(0xFF000000);
  560.           OUT_RING(0xFF000000);
  561.  
  562.           OUT_RING((blit->src_x<<16)|blit->src_y);
  563.           OUT_RING((blit->dst_x<<16)|blit->dst_y);
  564.           OUT_RING((blit->w<<16)|blit->h);
  565.  
  566.         COMMIT_RING();
  567.  
  568. #endif
  569.  
  570.        safe_sti(ifl);
  571.      };
  572.      return ERR_OK;
  573. }
  574.  
  575.  
  576. #if 0
  577.  
  578. int LockPixmap(userpixmap_t *io)
  579. {
  580.    pixmap_t *pixmap;
  581.    size_t    size;
  582.    void     *usermap;
  583.  
  584.    dbgprintf("Lock pixmap %x\n", io->pixmap);
  585.  
  586.    if(io->pixmap == (pixmap_t*)-1)
  587.      return ERR_PARAM;
  588.    else
  589.      pixmap = io->pixmap;
  590.  
  591.    if( (pixmap->flags & 1) == PX_LOCK )
  592.      return ERR_PARAM;
  593.  
  594.    size = (pixmap->pitch*pixmap->width+4095) & ~ 4095;
  595.    if (usermap = UserAlloc(size))
  596.    {
  597.      CommitPages(usermap, ((u32_t)pixmap->raw+rhd.PhisBase)|7|(1<<9), size);
  598.      pixmap->flags |= PX_LOCK;
  599.      pixmap->usermap = usermap;
  600.      io->usermap = usermap;
  601.      io->pitch   = pixmap->pitch;
  602.      dbgprintf("map at %x\n", io->usermap);
  603.  
  604.      return ERR_OK;
  605.    }
  606.    else
  607.      return ERR_PARAM;
  608. };
  609.  
  610. int UnlockPixmap(userpixmap_t *io)
  611. {
  612.   pixmap_t *pixmap;
  613.   size_t    size;
  614.  
  615.   dbgprintf("Unlock pixmap %x\n", io->pixmap);
  616.  
  617.   if(io->pixmap == (pixmap_t*)-1)
  618.     return ERR_PARAM;
  619.   else
  620.     pixmap = io->pixmap;
  621.  
  622.   if( (pixmap->flags & 1) != PX_LOCK )
  623.     return ERR_PARAM;
  624.  
  625. /*   Sanity checks  */
  626.  
  627.   if( (pixmap->usermap == 0)||
  628.       ((u32_t)pixmap->usermap >= 0x80000000) ||
  629.       ((u32_t)pixmap->usermap & 4095)
  630.     )
  631.     return ERR_PARAM;
  632.  
  633.   size = (pixmap->pitch*pixmap->width+4095) & ~ 4095;
  634.  
  635.   UnmapPages(pixmap->usermap, size);
  636.   UserFree(pixmap->usermap);
  637.   pixmap->usermap =  NULL;
  638.   pixmap->flags  &= ~PX_LOCK;
  639.   io->usermap     =  NULL;
  640.   io->pitch       =  0;
  641.  
  642.   return ERR_OK;
  643. };
  644.  
  645. #endif
  646.