Subversion Repositories Kolibri OS

Rev

Rev 880 | 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;
  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(6);
  36.  
  37.         OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4));
  38.  
  39.         OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  40.                  RADEON_GMC_BRUSH_SOLID_COLOR      |
  41.                  RADEON_GMC_DST_32BPP              |
  42.                  RADEON_GMC_SRC_DATATYPE_COLOR     |
  43.                  R5XX_GMC_CLR_CMP_CNTL_DIS         |
  44.                  R5XX_GMC_WR_MSK_DIS               |
  45.                  R5XX_ROP3_P
  46.                 );
  47.  
  48.         OUT_RING(dstpixmap->pitch_offset);
  49.         OUT_RING(io->color);
  50.         OUT_RING( 0 );
  51.         OUT_RING((dstpixmap->width<<16)|dstpixmap->height);
  52.       COMMIT_RING();
  53.  
  54. #endif
  55.  
  56.      safe_sti(ifl);
  57.  
  58.      return ERR_OK;
  59. }
  60.  
  61.  
  62. int Line(io_draw_t *draw)
  63. {
  64.      local_pixmap_t *dstpixmap;
  65.      clip_t clip;
  66.      int x0, y0, x1, y1;
  67.  
  68.      dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ;
  69.  
  70.      x0 = draw->x0;
  71.      y0 = draw->y0;
  72.  
  73.      x1 = draw->x1;
  74.      y1 = draw->y1;
  75.  
  76.      clip.xmin = 0;
  77.      clip.ymin = 0;
  78.      clip.xmax = dstpixmap->width-1;
  79.      clip.ymax = dstpixmap->height-1;
  80.  
  81.      if ( !LineClip(&clip, &x0, &y0, &x1, &y1 ))
  82.      {
  83.         u32_t ifl;
  84.         u32_t *ring, write;
  85.  
  86.         ifl = safe_cli();
  87.  
  88. #if R300_PIO
  89.  
  90.         R5xxFIFOWait(6);
  91.  
  92.         OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  93.                RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  94.                RADEON_GMC_BRUSH_SOLID_COLOR      |
  95.                RADEON_GMC_DST_32BPP              |
  96.                RADEON_GMC_SRC_DATATYPE_COLOR     |
  97.                R5XX_GMC_CLR_CMP_CNTL_DIS         |
  98.                R5XX_GMC_WR_MSK_DIS               |
  99.                R5XX_ROP3_P
  100.               );
  101.  
  102.         OUTREG(R5XX_DST_LINE_PATCOUNT, 0x55 << R5XX_BRES_CNTL_SHIFT);
  103.  
  104.         OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color);
  105.         OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  106.  
  107.         OUTREG(R5XX_DST_LINE_START,(y0<<16)|x0);
  108.         OUTREG(R5XX_DST_LINE_END,(y1<<16)|x1);
  109. #else
  110.        BEGIN_RING(6);
  111.  
  112.          OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_POLYLINE, 4));
  113.          OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  114.                   RADEON_GMC_BRUSH_SOLID_COLOR      |
  115.                   RADEON_GMC_DST_32BPP              |
  116.                   RADEON_GMC_SRC_DATATYPE_COLOR     |
  117.                   R5XX_GMC_CLR_CMP_CNTL_DIS         |
  118.                   R5XX_GMC_WR_MSK_DIS               |
  119.                   R5XX_ROP3_P);
  120.  
  121.          OUT_RING(dstpixmap->pitch_offset);
  122.          OUT_RING(draw->color);
  123.          OUT_RING((y0<<16)|x0);
  124.          OUT_RING((y1<<16)|x1);
  125.        COMMIT_RING();
  126. #endif
  127.         safe_sti(ifl);
  128.      };
  129.      return ERR_OK;
  130. }
  131.  
  132. int DrawRect(io_draw_t* draw)
  133. {
  134.      int x0, y0, x1, y1, xend, yend;
  135.  
  136.      local_pixmap_t *dstpixmap;
  137.      clip_t dst_clip;
  138.  
  139.      dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ;
  140.  
  141.      x0 = draw->x0;
  142.      y0 = draw->y0;
  143.  
  144.      x1 = xend = x0 + draw->w - 1;
  145.      y1 = yend = y0 + draw->h - 1;
  146.  
  147.      dst_clip.xmin = 0;
  148.      dst_clip.ymin = 0;
  149.      dst_clip.xmax = dstpixmap->width-1;
  150.      dst_clip.ymax = dstpixmap->height-1;
  151.  
  152.  
  153. //  dbgprintf("draw rect x0:%d, y0:%d, x1:%d, y1:%d, color: %x\n",
  154. //             x0, y0, x1, y1, draw->color);
  155.  
  156.      if( ! BlockClip( &dst_clip, &x0, &y0, &x1, &y1))
  157.      {
  158.         u32_t *ring;
  159.         u32_t ifl;
  160.         int w, h;
  161.  
  162.         w = x1 - x0 + 1;
  163.         h = y1 - y0 + 1;
  164.  
  165.         ifl = safe_cli();
  166.  
  167. #if R300_PIO
  168.  
  169.         R5xxFIFOWait(6);
  170.  
  171.         OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  172.                RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  173.                RADEON_GMC_BRUSH_SOLID_COLOR      |
  174.                RADEON_GMC_DST_32BPP              |
  175.                RADEON_GMC_SRC_DATATYPE_COLOR     |
  176.                R5XX_GMC_CLR_CMP_CNTL_DIS         |
  177.                R5XX_GMC_WR_MSK_DIS               |
  178.                R5XX_ROP3_P
  179.               );
  180.  
  181.         OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color);
  182.         OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
  183.         OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  184.         OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  185.         OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|h);
  186.  
  187.         if( draw->color != draw->border)
  188.         {
  189.            OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->border);
  190.  
  191.            if( y0 == draw->y0)
  192.            {
  193.               R5xxFIFOWait(2);
  194.  
  195.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  196.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  197.               y0++;
  198.               h--;
  199.            }
  200.            if( y1 == yend )
  201.            {
  202.               R5xxFIFOWait(2);
  203.  
  204.               OUTREG(R5XX_DST_Y_X,(y1<<16)|x0);
  205.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  206.               h--;
  207.            }
  208.            if( (h > 0) && (x0 == draw->x0))
  209.            {
  210.               R5xxFIFOWait(2);
  211.  
  212.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  213.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  214.            }
  215.            if( (h > 0) && (x1 == xend))
  216.            {
  217.               R5xxFIFOWait(2);
  218.  
  219.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x1);
  220.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  221.            }
  222.         };
  223. #else
  224.  
  225.       BEGIN_RING(64);
  226.  
  227.         OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4));
  228.  
  229.         OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  230.                  RADEON_GMC_BRUSH_SOLID_COLOR      |
  231.                  RADEON_GMC_DST_32BPP              |
  232.                  RADEON_GMC_SRC_DATATYPE_COLOR     |
  233.                  R5XX_GMC_CLR_CMP_CNTL_DIS         |
  234.                  R5XX_GMC_WR_MSK_DIS               |
  235.                  R5XX_ROP3_P
  236.                 );
  237.  
  238.         OUT_RING(dstpixmap->pitch_offset);
  239.         OUT_RING(draw->color);
  240.         OUT_RING((x0<<16)|y0);
  241.         OUT_RING((w<<16)|h);
  242.         OUT_RING(CP_PACKET2());
  243.         OUT_RING(CP_PACKET2());
  244.  
  245.         if( draw->color != draw->border)
  246.         {
  247.            if( y0 == draw->y0) {
  248.               OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4));
  249.               OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  250.                        RADEON_GMC_BRUSH_SOLID_COLOR      |
  251.                        RADEON_GMC_DST_32BPP              |
  252.                        RADEON_GMC_SRC_DATATYPE_COLOR     |
  253.                        R5XX_GMC_CLR_CMP_CNTL_DIS         |
  254.                        R5XX_GMC_WR_MSK_DIS               |
  255.                        R5XX_ROP3_P
  256.                       );
  257.  
  258.               OUT_RING(dstpixmap->pitch_offset);
  259.               OUT_RING(draw->border);
  260.               OUT_RING((x0<<16)|y0);
  261.               OUT_RING((w<<16)|1);
  262.         OUT_RING(CP_PACKET2());
  263.         OUT_RING(CP_PACKET2());
  264.  
  265.            //   y0++;
  266.            //   h--;
  267.            }
  268.            if( y1 == yend ) {
  269.               OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4));
  270.               OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  271.                        RADEON_GMC_BRUSH_SOLID_COLOR      |
  272.                        RADEON_GMC_DST_32BPP              |
  273.                        RADEON_GMC_SRC_DATATYPE_COLOR     |
  274.                        R5XX_GMC_CLR_CMP_CNTL_DIS         |
  275.                        R5XX_GMC_WR_MSK_DIS               |
  276.                        R5XX_ROP3_P
  277.                       );
  278.  
  279.               OUT_RING(dstpixmap->pitch_offset);
  280.               OUT_RING(draw->border);
  281.               OUT_RING((x0<<16)|y1);
  282.               OUT_RING((w<<16)|1);
  283.         OUT_RING(CP_PACKET2());
  284.         OUT_RING(CP_PACKET2());
  285.  
  286.             //  h--;
  287.            }
  288.            if( (h > 0) && (x0 == draw->x0)) {
  289.               OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4));
  290.               OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  291.                        RADEON_GMC_BRUSH_SOLID_COLOR      |
  292.                        RADEON_GMC_DST_32BPP              |
  293.                        RADEON_GMC_SRC_DATATYPE_COLOR     |
  294.                        R5XX_GMC_CLR_CMP_CNTL_DIS         |
  295.                        R5XX_GMC_WR_MSK_DIS               |
  296.                        R5XX_ROP3_P
  297.                       );
  298.  
  299.               OUT_RING(dstpixmap->pitch_offset);
  300.               OUT_RING(draw->border);
  301.               OUT_RING((x0<<16)|y0);
  302.               OUT_RING((1<<16)|h);
  303.         OUT_RING(CP_PACKET2());
  304.         OUT_RING(CP_PACKET2());
  305.  
  306.            }
  307.            if( (h > 0) && (x1 == xend)) {
  308.               OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4));
  309.               OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  310.                        RADEON_GMC_BRUSH_SOLID_COLOR      |
  311.                        RADEON_GMC_DST_32BPP              |
  312.                        RADEON_GMC_SRC_DATATYPE_COLOR     |
  313.                        R5XX_GMC_CLR_CMP_CNTL_DIS         |
  314.                        R5XX_GMC_WR_MSK_DIS               |
  315.                        R5XX_ROP3_P
  316.                       );
  317.  
  318.               OUT_RING(dstpixmap->pitch_offset);
  319.               OUT_RING(draw->border);
  320.               OUT_RING((x1<<16)|y0);
  321.               OUT_RING((1<<16)|h);
  322.         OUT_RING(CP_PACKET2());
  323.         OUT_RING(CP_PACKET2());
  324.  
  325.            }
  326.         };
  327.  
  328. /*
  329.  
  330.         CP_REG(R5XX_DP_GUI_MASTER_CNTL,
  331.                  RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  332.                  RADEON_GMC_BRUSH_SOLID_COLOR      |
  333.                  RADEON_GMC_DST_32BPP              |
  334.                  RADEON_GMC_SRC_DATATYPE_COLOR     |
  335.                  R5XX_GMC_CLR_CMP_CNTL_DIS         |
  336.                  R5XX_GMC_WR_MSK_DIS               |
  337.                  R5XX_ROP3_P
  338.                 );
  339.         CP_REG(R5XX_DP_BRUSH_FRGD_CLR, draw->color);
  340.         CP_REG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
  341.  
  342.         CP_REG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  343.         CP_REG(R5XX_DST_Y_X,(y0<<16)|x0);
  344.         CP_REG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|h);
  345.         if( draw->color != draw->border)
  346.         {
  347.         CP_REG(R5XX_DP_GUI_MASTER_CNTL,
  348.                  RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  349.                  RADEON_GMC_BRUSH_SOLID_COLOR      |
  350.                  RADEON_GMC_DST_32BPP              |
  351.                  RADEON_GMC_SRC_DATATYPE_COLOR     |
  352.                  R5XX_GMC_CLR_CMP_CNTL_DIS         |
  353.                  R5XX_GMC_WR_MSK_DIS               |
  354.                  R5XX_ROP3_P
  355.                 );
  356.            CP_REG(R5XX_DP_BRUSH_FRGD_CLR, draw->border);
  357.         CP_REG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
  358.  
  359.         CP_REG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  360.  
  361.  
  362.            if( y0 == draw->y0) {
  363.               CP_REG(R5XX_DST_Y_X,(y0<<16)|x0);
  364.               CP_REG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  365.               y0++;
  366.               h--;
  367.            }
  368.            if( y1 == yend ) {
  369.               CP_REG(R5XX_DST_Y_X,(y1<<16)|x0);
  370.               CP_REG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  371.               h--;
  372.            }
  373.            if( (h > 0) && (x0 == draw->x0)) {
  374.               CP_REG(R5XX_DST_Y_X,(y0<<16)|x0);
  375.               CP_REG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  376.            }
  377.            if( (h > 0) && (x1 == xend)) {
  378.               CP_REG(R5XX_DST_Y_X,(y0<<16)|x1);
  379.               CP_REG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  380.            }
  381.         };
  382. */
  383.  
  384.       COMMIT_RING();
  385. #endif
  386.         safe_sti(ifl);
  387.      };
  388.      return ERR_OK;
  389. }
  390.  
  391. int FillRect(io_fill_t *fill)
  392. {
  393.      local_pixmap_t *dstpixmap;
  394.      clip_t dst_clip;
  395.      int x0, y0, x1, y1, xend, yend;
  396.  
  397.      dstpixmap = (fill->dstpix == (void*)-1) ? &scr_pixmap : fill->dstpix ;
  398.  
  399.      x0 = fill->x;
  400.      y0 = fill->y;
  401.  
  402.      xend = x1 = x0 + fill->w - 1;
  403.      yend = y1 = y0 + fill->h - 1;
  404.  
  405.      dst_clip.xmin = 0;
  406.      dst_clip.ymin = 0;
  407.      dst_clip.xmax = dstpixmap->width-1;
  408.      dst_clip.ymax = dstpixmap->height-1;
  409.  
  410. //  dbgprintf("fill rect x0:%d, y0:%d, x1:%d, y1:%d\n",
  411. //             x0, y0, x1, y1);
  412.  
  413.      if( ! BlockClip(&dst_clip, &x0, &y0, &x1, &y1))
  414.      {
  415.         u32_t *ring, write;
  416.         u32_t ifl;
  417.  
  418.         int w = x1 - x0 + 1;
  419.         int h = y1 - y0 + 1;
  420.  
  421.         ifl = safe_cli();
  422.  
  423. #if R300_PIO
  424.  
  425.         R5xxFIFOWait(9);
  426.  
  427.         OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  428.                RADEON_GMC_DST_PITCH_OFFSET_CNTL |
  429.                R5XX_GMC_BRUSH_8X8_MONO_FG_BG    |
  430.                RADEON_GMC_DST_32BPP             |
  431.                R5XX_GMC_SRC_DATATYPE_COLOR      |
  432.                R5XX_GMC_CLR_CMP_CNTL_DIS        |
  433.                R5XX_GMC_WR_MSK_DIS              |
  434.                R5XX_ROP3_P
  435.                );
  436.  
  437.         OUTREG(R5XX_DP_BRUSH_BKGD_CLR, fill->bkcolor);
  438.         OUTREG(R5XX_DP_BRUSH_FRGD_CLR, fill->fcolor);
  439.  
  440.         OUTREG(R5XX_BRUSH_DATA0, fill->bmp0);
  441.         OUTREG(R5XX_BRUSH_DATA1, fill->bmp1);
  442.  
  443.         OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
  444.         OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  445.  
  446.         OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  447.         OUTREG(R5XX_DST_HEIGHT_WIDTH,(h<<16)|w);
  448.  
  449.         if( (fill->border & 0xFF000000) != 0)
  450.         {
  451.            R5xxFIFOWait(2);
  452.  
  453.            OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  454.                   RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  455.                   RADEON_GMC_BRUSH_SOLID_COLOR      |
  456.                   RADEON_GMC_DST_32BPP              |
  457.                   RADEON_GMC_SRC_DATATYPE_COLOR     |
  458.                   R5XX_GMC_CLR_CMP_CNTL_DIS         |
  459.                   R5XX_GMC_WR_MSK_DIS               |
  460.                   R5XX_ROP3_P
  461.                  );
  462.  
  463.            OUTREG(R5XX_DP_BRUSH_FRGD_CLR, fill->border);
  464.  
  465.            if( y0 == fill->y)
  466.            {
  467.               R5xxFIFOWait(2);
  468.  
  469.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  470.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  471.               y0++;
  472.               h--;
  473.            }
  474.            if( y1 == yend )
  475.            {
  476.               R5xxFIFOWait(2);
  477.  
  478.               OUTREG(R5XX_DST_Y_X,(y1<<16)|x0);
  479.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  480.               h--;
  481.            }
  482.            if( (h > 0) && (x0 == fill->x))
  483.            {
  484.               R5xxFIFOWait(2);
  485.  
  486.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x0);
  487.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  488.            }
  489.            if( (h > 0) && (x1 == xend))
  490.            {
  491.               R5xxFIFOWait(2);
  492.  
  493.               OUTREG(R5XX_DST_Y_X,(y0<<16)|x1);
  494.               OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  495.            }
  496.         };
  497.  
  498.  
  499. #else
  500.       BEGIN_RING(9+10*2);
  501.  
  502.         OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT, 7));
  503.         OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL    |
  504.                  R5XX_GMC_BRUSH_8X8_MONO_FG_BG       |
  505.                  RADEON_GMC_DST_32BPP                |
  506.                  RADEON_GMC_SRC_DATATYPE_COLOR       |
  507.                  R5XX_GMC_CLR_CMP_CNTL_DIS           |
  508.                  R5XX_GMC_WR_MSK_DIS                 |
  509.                  R5XX_ROP3_P
  510.                 );
  511.  
  512.         OUT_RING(dstpixmap->pitch_offset);
  513.         OUT_RING(fill->bkcolor);
  514.         OUT_RING(fill->fcolor);
  515.  
  516.         OUT_RING(fill->bmp0);
  517.         OUT_RING(fill->bmp1);
  518.  
  519.         OUT_RING((y0<<16)|x0);
  520.         OUT_RING((y1<<16)|x1);
  521.  
  522.         if( (fill->border & 0xFF000000) != 0)
  523.         {
  524.            CP_REG(R5XX_DP_GUI_MASTER_CNTL,
  525.                   RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  526.                   RADEON_GMC_BRUSH_SOLID_COLOR      |
  527.                   RADEON_GMC_DST_32BPP              |
  528.                   RADEON_GMC_SRC_DATATYPE_COLOR     |
  529.                   R5XX_GMC_CLR_CMP_CNTL_DIS         |
  530.                   R5XX_GMC_WR_MSK_DIS               |
  531.                   R5XX_ROP3_P
  532.                  );
  533.  
  534.            CP_REG(R5XX_DP_BRUSH_FRGD_CLR, fill->border);
  535.  
  536.            if( y0 == fill->y)
  537.            {
  538.               CP_REG(R5XX_DST_Y_X,(y0<<16)|x0);
  539.               CP_REG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  540.               y0++;
  541.               h--;
  542.            }
  543.            if( y1 == yend )
  544.            {
  545.               CP_REG(R5XX_DST_Y_X,(y1<<16)|x0);
  546.               CP_REG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1);
  547.               h--;
  548.            }
  549.            if( (h > 0) && (x0 == fill->x))
  550.            {
  551.               CP_REG(R5XX_DST_Y_X,(y0<<16)|x0);
  552.               CP_REG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  553.            }
  554.            if( (h > 0) && (x1 == xend))
  555.            {
  556.               CP_REG(R5XX_DST_Y_X,(y0<<16)|x1);
  557.               CP_REG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h);
  558.            }
  559.         };
  560.  
  561.       COMMIT_RING();
  562.  
  563. #endif
  564.         safe_sti(ifl);
  565.      };
  566.      return ERR_OK;
  567. };
  568.  
  569.  
  570.  
  571. int Blit(io_blit_t *blit)
  572. {
  573.      clip_t src_clip, dst_clip;
  574.  
  575.      local_pixmap_t *srcpixmap;
  576.      local_pixmap_t *dstpixmap;
  577.  
  578.      //dbgprintf("Pixblit src: %x dst: %x\n",blit->srcpix, blit->dstpix);
  579.  
  580.      dstpixmap = (blit->dstpix == (void*)-1) ? &scr_pixmap : blit->dstpix ;
  581.      srcpixmap = (blit->srcpix == (void*)-1) ? &scr_pixmap : blit->srcpix ;
  582.  
  583.      //dbgprintf("srcpixmap: %x dstpixmap: %x\n",srcpixmap, dstpixmap);
  584.  
  585.      //dbgprintf("dst.width: %d dst.height: %d\n", dstpixmap->width,dstpixmap->height);
  586.      //dbgprintf("src.width: %d src.height: %d\n", srcpixmap->width,srcpixmap->height);
  587.      //dbgprintf("srcpitch: %x dstpitch: %x\n",
  588.      //           srcpixmap->pitch_offset,dstpixmap->pitch_offset);
  589.  
  590.      src_clip.xmin = 0;
  591.      src_clip.ymin = 0;
  592.      src_clip.xmax = srcpixmap->width-1;
  593.      src_clip.ymax = srcpixmap->height-1;
  594.  
  595.      dst_clip.xmin = 0;
  596.      dst_clip.ymin = 0;
  597.      dst_clip.xmax = dstpixmap->width-1;
  598.      dst_clip.ymax = dstpixmap->height-1;
  599.  
  600.      if( !blit_clip(&dst_clip, &blit->dst_x, &blit->dst_y,
  601.                     &src_clip, &blit->src_x, &blit->src_y,
  602.                     &blit->w, &blit->h) )
  603.      {
  604.         u32_t *ring, write;
  605.         u32_t ifl;
  606.  
  607.         ifl = safe_cli();
  608.  
  609. #if R300_PIO
  610.  
  611.         R5xxFIFOWait(7);
  612.  
  613.         OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  614.                RADEON_GMC_SRC_PITCH_OFFSET_CNTL  |
  615.                RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  616.                RADEON_GMC_BRUSH_NONE             |
  617.                RADEON_GMC_DST_32BPP              |
  618.                RADEON_GMC_SRC_DATATYPE_COLOR     |
  619.                RADEON_DP_SRC_SOURCE_MEMORY       |
  620.                R5XX_GMC_CLR_CMP_CNTL_DIS         |
  621.                R5XX_GMC_WR_MSK_DIS               |
  622.                R5XX_ROP3_S
  623.               );
  624.  
  625.         OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
  626.  
  627.         OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  628.         OUTREG(R5XX_SRC_PITCH_OFFSET, srcpixmap->pitch_offset);
  629.  
  630.         OUTREG(R5XX_SRC_Y_X,(blit->src_y<<16)|blit->src_x);
  631.         OUTREG(R5XX_DST_Y_X,(blit->dst_y<<16)|blit->dst_x);
  632.         OUTREG(R5XX_DST_HEIGHT_WIDTH,(blit->h<<16)|blit->w);
  633.  
  634. #else
  635.         BEGIN_RING(7);
  636.  
  637.           OUT_RING(CP_PACKET3(RADEON_CNTL_BITBLT, 5));
  638.  
  639.           OUT_RING(RADEON_GMC_SRC_PITCH_OFFSET_CNTL  |
  640.                    RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  641.                    RADEON_GMC_BRUSH_NONE             |
  642.                    RADEON_GMC_DST_32BPP              |
  643.                    RADEON_GMC_SRC_DATATYPE_COLOR     |
  644.                    RADEON_DP_SRC_SOURCE_MEMORY       |
  645.                    R5XX_GMC_CLR_CMP_CNTL_DIS         |
  646.                    R5XX_GMC_WR_MSK_DIS               |
  647.                    R5XX_ROP3_S
  648.                   );
  649.  
  650.           OUT_RING(srcpixmap->pitch_offset);
  651.           OUT_RING(dstpixmap->pitch_offset);
  652.  
  653.           OUT_RING((blit->src_x<<16)|blit->src_y);
  654.           OUT_RING((blit->dst_x<<16)|blit->dst_y);
  655.           OUT_RING((blit->w<<16)|blit->h);
  656.         COMMIT_RING();
  657.  
  658. #endif
  659.        safe_sti(ifl);
  660.      };
  661.      return ERR_OK;
  662. };
  663.  
  664.  
  665. int BlitTransparent(io_blit_t *blit)
  666. {
  667.      clip_t src_clip, dst_clip;
  668.  
  669.      local_pixmap_t *srcpixmap;
  670.      local_pixmap_t *dstpixmap;
  671.  
  672.     // dbgprintf("Transblit src: %x dst: %x\n",blit->srcpix, blit->dstpix);
  673.  
  674.      dstpixmap = (blit->dstpix == (void*)-1) ? &scr_pixmap : blit->dstpix ;
  675.      srcpixmap = (blit->srcpix == (void*)-1) ? &scr_pixmap : blit->srcpix ;
  676.  
  677.      //dbgprintf("srcpixmap: %x dstpixmap: %x\n",srcpixmap, dstpixmap);
  678.  
  679.      //dbgprintf("dst.width: %d dst.height: %d\n", dstpixmap->width,dstpixmap->height);
  680.      //dbgprintf("src.width: %d src.height: %d\n", srcpixmap->width,srcpixmap->height);
  681.      //dbgprintf("srcpitch: %x dstpitch: %x\n",
  682.      //           srcpixmap->pitch_offset,dstpixmap->pitch_offset);
  683.      src_clip.xmin = 0;
  684.      src_clip.ymin = 0;
  685.      src_clip.xmax = srcpixmap->width-1;
  686.      src_clip.ymax = srcpixmap->height-1;
  687.  
  688.      dst_clip.xmin = 0;
  689.      dst_clip.ymin = 0;
  690.      dst_clip.xmax = dstpixmap->width-1;
  691.      dst_clip.ymax = dstpixmap->height-1;
  692.  
  693.      if( !blit_clip(&dst_clip, &blit->dst_x, &blit->dst_y,
  694.                     &src_clip, &blit->src_x, &blit->src_y,
  695.                     &blit->w, &blit->h) )
  696.      {
  697.         u32_t *ring, write;
  698.  
  699.         u32_t ifl;
  700.  
  701.         ifl = safe_cli();
  702.  
  703. #if R300_PIO
  704.  
  705.         R5xxFIFOWait(10);
  706.  
  707.         OUTREG(R5XX_DP_GUI_MASTER_CNTL,
  708.                RADEON_GMC_SRC_PITCH_OFFSET_CNTL  |
  709.                RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  710.                RADEON_GMC_BRUSH_NONE             |
  711.                RADEON_GMC_DST_32BPP              |
  712.                RADEON_GMC_SRC_DATATYPE_COLOR     |
  713.                RADEON_DP_SRC_SOURCE_MEMORY       |
  714.                R5XX_GMC_WR_MSK_DIS               |
  715.                R5XX_ROP3_S
  716.               );
  717.  
  718.         OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM);
  719.  
  720.         OUTREG(R5XX_CLR_CMP_CLR_SRC, blit->key);
  721.         OUTREG(R5XX_CLR_CMP_MASK, R5XX_CLR_CMP_MSK);
  722.         OUTREG(R5XX_CLR_CMP_CNTL, R5XX_SRC_CMP_EQ_COLOR | R5XX_CLR_CMP_SRC_SOURCE);
  723.  
  724.         OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset);
  725.         OUTREG(R5XX_SRC_PITCH_OFFSET, srcpixmap->pitch_offset);
  726.  
  727.         OUTREG(R5XX_SRC_Y_X,(blit->src_y<<16)|blit->src_x);
  728.         OUTREG(R5XX_DST_Y_X,(blit->dst_y<<16)|blit->dst_x);
  729.         OUTREG(R5XX_DST_HEIGHT_WIDTH,(blit->h<<16)|blit->w);
  730.  
  731. #else
  732.  
  733.         BEGIN_RING(10);
  734.  
  735.           OUT_RING(CP_PACKET3(RADEON_CNTL_TRANBLT, 8));
  736.  
  737.           OUT_RING(RADEON_GMC_SRC_PITCH_OFFSET_CNTL  |
  738.                    RADEON_GMC_DST_PITCH_OFFSET_CNTL  |
  739.                    RADEON_GMC_BRUSH_NONE             |
  740.                    RADEON_GMC_DST_32BPP              |
  741.                    RADEON_GMC_SRC_DATATYPE_COLOR     |
  742.                    RADEON_DP_SRC_SOURCE_MEMORY       |
  743.                    R5XX_GMC_WR_MSK_DIS               |
  744.                    R5XX_ROP3_S
  745.                   );
  746.  
  747.           OUT_RING(srcpixmap->pitch_offset);
  748.           OUT_RING(dstpixmap->pitch_offset);
  749.  
  750.           OUT_RING(R5XX_CLR_CMP_SRC_SOURCE | R5XX_SRC_CMP_EQ_COLOR);
  751.           OUT_RING(blit->key);
  752.           OUT_RING(0xFFFFFFFF);
  753.  
  754.           OUT_RING((blit->src_x<<16)|blit->src_y);
  755.           OUT_RING((blit->dst_x<<16)|blit->dst_y);
  756.           OUT_RING((blit->w<<16)|blit->h);
  757.  
  758.         COMMIT_RING();
  759.  
  760. #endif
  761.  
  762.        safe_sti(ifl);
  763.      };
  764.      return ERR_OK;
  765. }
  766.  
  767.  
  768. #if 0
  769.  
  770. int LockPixmap(userpixmap_t *io)
  771. {
  772.    pixmap_t *pixmap;
  773.    size_t    size;
  774.    void     *usermap;
  775.  
  776.    dbgprintf("Lock pixmap %x\n", io->pixmap);
  777.  
  778.    if(io->pixmap == (pixmap_t*)-1)
  779.      return ERR_PARAM;
  780.    else
  781.      pixmap = io->pixmap;
  782.  
  783.    if( (pixmap->flags & 1) == PX_LOCK )
  784.      return ERR_PARAM;
  785.  
  786.    size = (pixmap->pitch*pixmap->width+4095) & ~ 4095;
  787.    if (usermap = UserAlloc(size))
  788.    {
  789.      CommitPages(usermap, ((u32_t)pixmap->raw+rhd.PhisBase)|7|(1<<9), size);
  790.      pixmap->flags |= PX_LOCK;
  791.      pixmap->usermap = usermap;
  792.      io->usermap = usermap;
  793.      io->pitch   = pixmap->pitch;
  794.      dbgprintf("map at %x\n", io->usermap);
  795.  
  796.      return ERR_OK;
  797.    }
  798.    else
  799.      return ERR_PARAM;
  800. };
  801.  
  802. int UnlockPixmap(userpixmap_t *io)
  803. {
  804.   pixmap_t *pixmap;
  805.   size_t    size;
  806.  
  807.   dbgprintf("Unlock pixmap %x\n", io->pixmap);
  808.  
  809.   if(io->pixmap == (pixmap_t*)-1)
  810.     return ERR_PARAM;
  811.   else
  812.     pixmap = io->pixmap;
  813.  
  814.   if( (pixmap->flags & 1) != PX_LOCK )
  815.     return ERR_PARAM;
  816.  
  817. /*   Sanity checks  */
  818.  
  819.   if( (pixmap->usermap == 0)||
  820.       ((u32_t)pixmap->usermap >= 0x80000000) ||
  821.       ((u32_t)pixmap->usermap & 4095)
  822.     )
  823.     return ERR_PARAM;
  824.  
  825.   size = (pixmap->pitch*pixmap->width+4095) & ~ 4095;
  826.  
  827.   UnmapPages(pixmap->usermap, size);
  828.   UserFree(pixmap->usermap);
  829.   pixmap->usermap =  NULL;
  830.   pixmap->flags  &= ~PX_LOCK;
  831.   io->usermap     =  NULL;
  832.   io->pitch       =  0;
  833.  
  834.   return ERR_OK;
  835. };
  836.  
  837. #endif
  838.