Subversion Repositories Kolibri OS

Rev

Rev 868 | Blame | Last modification | View Log | Download | RSS feed

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