Subversion Repositories Kolibri OS

Rev

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

  1.  
  2.  
  3. #define R300_PIO        1
  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("/bd0/2/ati2d.log"))
  47.     {
  48.         printf("Can't open /rd/1/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.     for(i=0;i<6;i++)
  64.     {
  65.         if(rhd.memBase[i])
  66.             dbgprintf("Memory base_%d 0x%x size 0x%x\n",
  67.                       i,rhd.memBase[i],(1<<rhd.memsize[i]));
  68.     };
  69.     for(i=0;i<6;i++)
  70.     {
  71.         if(rhd.ioBase[i])
  72.             dbgprintf("Io base_%d 0x%x size 0x%x\n",
  73.                       i,rhd.ioBase[i],(1<<rhd.memsize[i]));
  74.     };
  75.     if(!RHDPreInit())
  76.         return 0;
  77.  
  78.     R5xx2DInit();
  79.  
  80. #if !R300_PIO
  81.  
  82.     Init3DEngine(&rhd);
  83.  
  84. #endif
  85.  
  86.     retval = RegService("HDRAW", srv_2d);
  87.     dbgprintf("reg service %s as: %x\n", "HDRAW", retval);
  88.  
  89.     return retval;
  90. };
  91.  
  92.  
  93. int __stdcall srv_2d(ioctl_t *io)
  94. {
  95.     u32_t *inp;
  96.     u32_t *outp;
  97.  
  98.     inp = io->input;
  99.     outp = io->output;
  100.  
  101.     switch(io->io_code)
  102.     {
  103.         case SRV_GETVERSION:
  104.             if(io->out_size==4)
  105.             {
  106.                 *outp = API_VERSION;
  107.                 return 0;
  108.             }
  109.             break;
  110.  
  111.         case PX_CREATE:
  112.             if(io->inp_size==7)
  113.                 return CreatePixmap((pixmap_t*)inp);
  114.             break;
  115.  
  116.         case PX_DESTROY:
  117.             if(io->inp_size==7)
  118.                 return DestroyPixmap((pixmap_t*)inp);
  119.             break;
  120.  
  121.         case PX_CLEAR:
  122.             if(io->inp_size==2)
  123.                 return ClearPixmap((io_clear_t*)inp);
  124.             break;
  125.  
  126.         case PX_DRAW_RECT:
  127.             if(io->inp_size==7)
  128.                 return DrawRect((io_draw_t*)inp);
  129.             break;
  130.  
  131.         case PX_FILL_RECT:
  132.             if(io->inp_size==10)
  133.                 return FillRect((io_fill_t*)inp);
  134.             break;
  135.  
  136.         case PX_LINE:
  137.             if(io->inp_size==6)
  138.                 return Line((io_draw_t*)inp);
  139.             break;
  140.  
  141.         case PX_BLIT:
  142.             if(io->inp_size==8)
  143.                 return Blit((io_blit_t*)inp);
  144.             break;
  145.  
  146.         case  PX_BLIT_TRANSPARENT:
  147.             if(io->inp_size==9)
  148.                 return BlitTransparent((io_blit_t*)inp);
  149.             break;
  150.  
  151. #if !R300_PIO
  152.  
  153.         case PX_BLIT_ALPHA:
  154.             if(io->inp_size==9)
  155.                 return RadeonComposite((io_blit_t*)inp);
  156.             break;
  157. #endif
  158.  
  159.         default:
  160.             return ERR_PARAM;
  161.   };
  162.  
  163.   return ERR_PARAM;
  164. }
  165.  
  166.  
  167. #include "init.c"
  168. #include "pci.c"
  169. #include "ati_mem.c"
  170.  
  171. #include "init_cp.c"
  172.  
  173. #include "r500.inc"
  174.  
  175. #include "clip.inc"
  176. #include "pixmap.inc"
  177. #include "accel_2d.inc"
  178.  
  179. #if !R300_PIO
  180.  
  181. #include "init_3d.inc"
  182. #include "blend.inc"
  183.  
  184. #endif
  185.  
  186.  
  187.