Subversion Repositories Kolibri OS

Rev

Rev 1406 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2.  
  3. #define R300_PIO        0
  4.  
  5.  
  6. #define API_VERSION     0x01000100
  7.  
  8. #define SRV_GETVERSION  0
  9.  
  10.  
  11. #include "types.h"
  12.  
  13. #include <stdio.h>
  14. #include <malloc.h>
  15. #include <memory.h>
  16.  
  17. #include "pci.h"
  18.  
  19. #include "syscall.h"
  20.  
  21. #include "radeon_reg.h"
  22.  
  23. #include "atihw.h"
  24.  
  25. #include "accel_2d.h"
  26.  
  27. RHD_t rhd __attribute__ ((aligned (128)));    /* reduce cache lock */
  28.  
  29. static clip_t  clip;
  30.  
  31. static local_pixmap_t scr_pixmap;
  32.  
  33.  
  34. int __stdcall srv_2d(ioctl_t *io);
  35.  
  36. u32_t __stdcall drvEntry(int action)
  37. {
  38.     RHDPtr rhdPtr;
  39.     u32_t retval;
  40.  
  41.     int i;
  42.  
  43.     if(action != 1)
  44.         return 0;
  45.  
  46.     if(!dbg_open("/sys/drivers/ati2d.log"))
  47.     {
  48.         printf("Can't open /sys/drivers/ati2d.log\nExit\n");
  49.         return 0;
  50.     }
  51.     if( GetScreenBpp() != 32)
  52.     {
  53.         dbgprintf("32 bpp dispaly mode required !\nExit\t");
  54.         return 0;
  55.     }
  56.  
  57.     if((rhdPtr=FindPciDevice())==NULL)
  58.     {
  59.         dbgprintf("Device not found\n");
  60.         return 0;
  61.     };
  62.  
  63.     dbgprintf("detect %s GART\n",
  64.                rhd.gart_type == RADEON_IS_PCIE ? "PCIE":"PCI");
  65.  
  66.     for(i=0;i<6;i++)
  67.     {
  68.         if(rhd.memBase[i])
  69.             dbgprintf("Memory base_%d 0x%x size 0x%x\n",
  70.                       i,rhd.memBase[i],(1<<rhd.memsize[i]));
  71.     };
  72.     for(i=0;i<6;i++)
  73.     {
  74.         if(rhd.ioBase[i])
  75.             dbgprintf("Io base_%d 0x%x size 0x%x\n",
  76.                       i,rhd.ioBase[i],(1<<rhd.memsize[i]));
  77.     };
  78.     if(!RHDPreInit())
  79.         return 0;
  80.  
  81.     R5xx2DInit();
  82.  
  83.     Init3DEngine(&rhd);
  84.  
  85.     retval = RegService("HDRAW", srv_2d);
  86.     dbgprintf("reg service %s as: %x\n", "HDRAW", retval);
  87.  
  88.     return retval;
  89. };
  90.  
  91.  
  92. int __stdcall srv_2d(ioctl_t *io)
  93. {
  94.     u32_t *inp;
  95.     u32_t *outp;
  96.  
  97.     inp = io->input;
  98.     outp = io->output;
  99.  
  100.     switch(io->io_code)
  101.     {
  102.         case SRV_GETVERSION:
  103.             if(io->out_size==4)
  104.             {
  105.                 *outp = API_VERSION;
  106.                 return 0;
  107.             }
  108.             break;
  109.  
  110.         case PX_CREATE:
  111.             if(io->inp_size==7)
  112.                 return CreatePixmap((pixmap_t*)inp);
  113.             break;
  114.  
  115.         case PX_DESTROY:
  116.             if(io->inp_size==7)
  117.                 return DestroyPixmap((pixmap_t*)inp);
  118.             break;
  119.  
  120.         case PX_CLEAR:
  121.             if(io->inp_size==2)
  122.                 return ClearPixmap((io_clear_t*)inp);
  123.             break;
  124.  
  125.         case PX_DRAW_RECT:
  126.             if(io->inp_size==7)
  127.                 return DrawRect((io_draw_t*)inp);
  128.             break;
  129.  
  130.         case PX_FILL_RECT:
  131.             if(io->inp_size==10)
  132.                 return FillRect((io_fill_t*)inp);
  133.             break;
  134.  
  135.         case PX_LINE:
  136.             if(io->inp_size==6)
  137.                 return Line((io_draw_t*)inp);
  138.             break;
  139.  
  140.         case PX_BLIT:
  141.             if(io->inp_size==8)
  142.                 return Blit((io_blit_t*)inp);
  143.             break;
  144.  
  145.         case  PX_BLIT_TRANSPARENT:
  146.             if(io->inp_size==9)
  147.                 return BlitTransparent((io_blit_t*)inp);
  148.             break;
  149.  
  150.         case PX_BLIT_ALPHA:
  151.             if(io->inp_size==9)
  152.                 return RadeonComposite((io_blit_t*)inp);
  153.             break;
  154.  
  155.         default:
  156.             return ERR_PARAM;
  157.   };
  158.  
  159.   return ERR_PARAM;
  160. }
  161.  
  162.  
  163. #include "init.c"
  164. #include "pci.c"
  165. #include "ati_mem.c"
  166.  
  167. #include "r500.inc"
  168.  
  169. #include "clip.inc"
  170. #include "pixmap.inc"
  171. #include "accel_2d.inc"
  172. #include "init_3d.inc"
  173. #include "blend.inc"
  174.  
  175. #if !R300_PIO
  176.  
  177. #include "init_cp.c"
  178.  
  179. #endif
  180.  
  181.  
  182.