Subversion Repositories Kolibri OS

Rev

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

  1. /**************************************************************************
  2.  
  3. Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
  4. Copyright © 2002 David Dawes
  5.  
  6. All Rights Reserved.
  7.  
  8. Permission is hereby granted, free of charge, to any person obtaining a
  9. copy of this software and associated documentation files (the
  10. "Software"), to deal in the Software without restriction, including
  11. without limitation the rights to use, copy, modify, merge, publish,
  12. distribute, sub license, and/or sell copies of the Software, and to
  13. permit persons to whom the Software is furnished to do so, subject to
  14. the following conditions:
  15.  
  16. The above copyright notice and this permission notice (including the
  17. next paragraph) shall be included in all copies or substantial portions
  18. of the Software.
  19.  
  20. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  23. IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
  24. ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27.  
  28. **************************************************************************/
  29.  
  30. /*
  31.  * Authors:
  32.  *   Keith Whitwell <keith@tungstengraphics.com>
  33.  *   David Dawes <dawes@xfree86.org>
  34.  *
  35.  */
  36.  
  37. #ifndef _SNA_H_
  38. #define _SNA_H_
  39.  
  40. #ifdef HAVE_CONFIG_H
  41. #include "config.h"
  42. #endif
  43.  
  44. #include <stdint.h>
  45. #include <memory.h>
  46. #include <malloc.h>
  47. #include <errno.h>
  48.  
  49. #include "intel_driver.h"
  50. #include "pciaccess.h"
  51.  
  52. #include "compiler.h"
  53.  
  54. //#define DBG(x)
  55. //#define DBG(x) ErrorF x
  56.  
  57. #define assert(x)
  58.  
  59.  
  60. int drmIoctl(int fd, unsigned long request, void *arg);
  61.  
  62.  
  63. #define SRV_GET_PCI_INFO            20
  64. #define SRV_GET_PARAM               21
  65. #define SRV_I915_GEM_CREATE         22
  66. #define SRV_DRM_GEM_CLOSE           23
  67. #define SRV_I915_GEM_PIN            24
  68. #define SRV_I915_GEM_SET_CACHEING   25
  69. #define SRV_I915_GEM_GET_APERTURE   26
  70. #define SRV_I915_GEM_PWRITE         27
  71. #define SRV_I915_GEM_BUSY           28
  72. #define SRV_I915_GEM_SET_DOMAIN     29
  73. #define SRV_I915_GEM_MMAP           30
  74. #define SRV_I915_GEM_THROTTLE       32
  75. #define SRV_FBINFO                  33
  76. #define SRV_I915_GEM_EXECBUFFER2    34
  77. #define SRV_MASK_UPDATE             35
  78.  
  79. #define SRV_I915_GEM_MMAP_GTT       31
  80.  
  81.  
  82. #define DRM_IOCTL_GEM_CLOSE         SRV_DRM_GEM_CLOSE
  83.  
  84. #define PIXMAN_FORMAT(bpp,type,a,r,g,b) (((bpp) << 24) |    \
  85.                                         ((type) << 16) |    \
  86.                                         ((a) << 12)    |    \
  87.                                         ((r) << 8) |        \
  88.                                         ((g) << 4) |        \
  89.                                         ((b)))
  90. #define PIXMAN_TYPE_OTHER       0
  91. #define PIXMAN_TYPE_A           1
  92. #define PIXMAN_TYPE_ARGB        2
  93. #define PIXMAN_TYPE_ABGR        3
  94. #define PIXMAN_TYPE_COLOR       4
  95. #define PIXMAN_TYPE_GRAY        5
  96. #define PIXMAN_TYPE_YUY2        6
  97. #define PIXMAN_TYPE_YV12        7
  98. #define PIXMAN_TYPE_BGRA        8
  99. #define PIXMAN_TYPE_RGBA        9
  100. #define PIXMAN_TYPE_ARGB_SRGB   10
  101.  
  102. /* 32bpp formats */
  103. typedef enum {
  104.     PIXMAN_a8r8g8b8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,8,8,8,8),
  105.     PIXMAN_x8r8g8b8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,8,8,8),
  106.     PIXMAN_a8b8g8r8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,8,8,8,8),
  107.     PIXMAN_x8b8g8r8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,8,8,8),
  108.     PIXMAN_b8g8r8a8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,8,8,8,8),
  109.     PIXMAN_b8g8r8x8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_BGRA,0,8,8,8),
  110.     PIXMAN_r8g8b8a8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,8,8,8,8),
  111.     PIXMAN_r8g8b8x8 =    PIXMAN_FORMAT(32,PIXMAN_TYPE_RGBA,0,8,8,8),
  112.     PIXMAN_x14r6g6b6 =   PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,6,6,6),
  113.     PIXMAN_x2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,0,10,10,10),
  114.     PIXMAN_a2r10g10b10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ARGB,2,10,10,10),
  115.     PIXMAN_x2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,0,10,10,10),
  116.     PIXMAN_a2b10g10r10 = PIXMAN_FORMAT(32,PIXMAN_TYPE_ABGR,2,10,10,10),
  117.  
  118.     PIXMAN_a8 =          PIXMAN_FORMAT(8,PIXMAN_TYPE_A,8,0,0,0)
  119.    
  120. } pixman_format_code_t;
  121.  
  122. typedef enum _PictFormatShort {
  123.  
  124.     PICT_a8r8g8b8 = PIXMAN_a8r8g8b8,
  125.     PICT_x8r8g8b8 = PIXMAN_x8r8g8b8,
  126.     PICT_a8b8g8r8 = PIXMAN_a8b8g8r8,
  127.     PICT_x8b8g8r8 = PIXMAN_x8b8g8r8,
  128.     PICT_b8g8r8a8 = PIXMAN_b8g8r8a8,
  129.     PICT_b8g8r8x8 = PIXMAN_b8g8r8x8,
  130.  
  131. /* 8bpp formats */
  132.     PICT_a8 = PIXMAN_a8,
  133.  
  134. /* 4bpp formats */
  135. } PictFormatShort;
  136.  
  137. #define RepeatNone                          0
  138. #define RepeatNormal                        1
  139. #define RepeatPad                           2
  140. #define RepeatReflect                       3
  141.  
  142. #define PictFilterNearest       0
  143. #define PictFilterBilinear      1
  144.  
  145. #define PictFilterFast          2
  146. #define PictFilterGood          3
  147. #define PictFilterBest          4
  148.  
  149. #define PictFilterConvolution   5
  150.  
  151. typedef int32_t                 pixman_fixed_16_16_t;
  152. typedef pixman_fixed_16_16_t    pixman_fixed_t;
  153.  
  154. struct pixman_transform
  155. {
  156.     pixman_fixed_t      matrix[3][3];
  157. };
  158.  
  159. typedef unsigned long   Picture;
  160. typedef unsigned long   PictFormat;
  161.  
  162. typedef struct _Pixmap  *PixmapPtr;
  163. typedef struct _Picture *PicturePtr;
  164. typedef struct _Drawable *DrawablePtr;
  165. typedef struct _PictFormat *PictFormatPtr;
  166.  
  167. typedef struct pixman_transform PictTransform, *PictTransformPtr;
  168.  
  169.  
  170.  
  171. typedef struct _Drawable {
  172.     unsigned char type;         /* DRAWABLE_<type> */
  173.     unsigned char class;        /* specific to type */
  174.     unsigned char depth;
  175.     unsigned char bitsPerPixel;
  176.     unsigned int   id;           /* resource id */
  177.     short x;                    /* window: screen absolute, pixmap: 0 */
  178.     short y;                    /* window: screen absolute, pixmap: 0 */
  179.     unsigned short width;
  180.     unsigned short height;
  181. } DrawableRec;
  182.  
  183. /*
  184.  * PIXMAP -- device dependent
  185.  */
  186.  
  187. typedef struct _Pixmap {
  188.     DrawableRec drawable;
  189. //    PrivateRec *devPrivates;
  190.     int refcnt;
  191.     int devKind;                /* This is the pitch of the pixmap, typically width*bpp/8. */
  192. //    DevUnion devPrivate;        /* When !NULL, devPrivate.ptr points to the raw pixel data. */
  193. #ifdef COMPOSITE
  194.     short screen_x;
  195.     short screen_y;
  196. #endif
  197.     unsigned usage_hint;        /* see CREATE_PIXMAP_USAGE_* */
  198.  
  199.     PixmapPtr master_pixmap;    /* pointer to master copy of pixmap for pixmap sharing */
  200. } PixmapRec;
  201.  
  202. typedef struct _PictFormat {
  203.     uint32_t id;
  204.     uint32_t format;              /* except bpp */
  205.     unsigned char type;
  206.     unsigned char depth;
  207. //    DirectFormatRec direct;
  208. //   IndexFormatRec index;
  209. } PictFormatRec;
  210.  
  211. typedef struct _Picture {
  212.     DrawablePtr pDrawable;
  213. //    PictFormatPtr pFormat;
  214.     PictFormatShort format;     /* PICT_FORMAT */
  215.     int refcnt;
  216.     uint32_t id;
  217.     unsigned int repeat:1;
  218.     unsigned int graphicsExposures:1;
  219.     unsigned int subWindowMode:1;
  220.     unsigned int polyEdge:1;
  221.     unsigned int polyMode:1;
  222.     unsigned int freeCompClip:1;
  223.     unsigned int clientClipType:2;
  224.     unsigned int componentAlpha:1;
  225.     unsigned int repeatType:2;
  226.     unsigned int filter:3;
  227. //    unsigned int stateChanges:CPLastBit;
  228. //    unsigned int unused:18 - CPLastBit;
  229.  
  230. //    PicturePtr alphaMap;
  231.  
  232. //    PictTransform *transform;
  233.  
  234. //    SourcePictPtr pSourcePict;
  235. //    xFixed *filter_params;
  236. //    int filter_nparams;
  237. } PictureRec;
  238.  
  239. #define PolyModePrecise                     0
  240. #define PolyModeImprecise                   1
  241.  
  242.  
  243. struct sna_fb
  244. {
  245.     uint32_t  width;
  246.     uint32_t  height;
  247.     uint32_t  pitch;
  248.     uint32_t  tiling;
  249.    
  250.     struct kgem_bo *fb_bo;
  251. };
  252.  
  253. struct pixman_box16
  254. {
  255.     int16_t x1, y1, x2, y2;
  256. };
  257.  
  258. typedef struct pixman_box16 BoxRec;
  259. typedef unsigned int   CARD32;
  260. typedef unsigned short CARD16;
  261.  
  262. #include "sna_render.h"
  263. #include "kgem.h"
  264.  
  265. #define GXclear                 0x0
  266. #define GXcopy                  0x3
  267.  
  268. #define PictOpClear             0
  269. #define PictOpSrc               1
  270. #define PictOpDst               2
  271. #define PictOpOver              3
  272. #define PictOpOverReverse       4
  273. #define PictOpIn                5
  274. #define PictOpInReverse         6
  275. #define PictOpOut               7
  276. #define PictOpOutReverse        8
  277. #define PictOpAtop              9
  278. #define PictOpAtopReverse       10
  279. #define PictOpXor               11
  280. #define PictOpAdd               12
  281. #define PictOpSaturate          13
  282. #define PictOpMaximum           13
  283.  
  284.  
  285.  
  286. struct sna {
  287.     unsigned flags;
  288. #define SNA_NO_WAIT             0x1
  289. #define SNA_NO_FLIP             0x2
  290. #define SNA_TRIPLE_BUFFER       0x4
  291. #define SNA_TEAR_FREE           0x10
  292. #define SNA_FORCE_SHADOW        0x20
  293.  
  294.         struct list flush_pixmaps;
  295.         struct list active_pixmaps;
  296.  
  297.  
  298.  
  299. //    int vblank_interval;
  300.  
  301. //    struct list deferred_free;
  302. //    struct list dirty_pixmaps;
  303. //    struct list active_pixmaps;
  304. //    struct list inactive_clock[2];
  305.  
  306.     unsigned int tiling;
  307. #define SNA_TILING_DISABLE  0x0
  308. #define SNA_TILING_FB       0x1
  309. #define SNA_TILING_2D       0x2
  310. #define SNA_TILING_ALL     (~0)
  311.  
  312.         struct pci_device *PciInfo;
  313.         const struct intel_device_info *info;
  314.  
  315. //    PicturePtr clear;
  316.     struct {
  317.         uint32_t fill_bo;
  318.         uint32_t fill_pixel;
  319.         uint32_t fill_alu;
  320.     } blt_state;
  321.     union {
  322. //        struct gen2_render_state gen2;
  323.         struct gen3_render_state gen3;
  324.         struct gen4_render_state gen4;
  325.         struct gen5_render_state gen5;
  326.         struct gen6_render_state gen6;
  327.                 struct gen7_render_state gen7;
  328.     } render_state;
  329.  
  330.  
  331.     /* Broken-out options. */
  332. //    OptionInfoPtr Options;
  333.  
  334.     /* Driver phase/state information */
  335. //    Bool suspended;
  336.  
  337.     struct kgem kgem;
  338.     struct sna_render render;
  339.  
  340. #if DEBUG_MEMORY
  341.         struct {
  342.                int shadow_pixels_allocs;
  343.                int cpu_bo_allocs;
  344.                size_t shadow_pixels_bytes;
  345.                size_t cpu_bo_bytes;
  346.         } debug_memory;
  347. #endif
  348. };
  349.  
  350. static inline struct sna *
  351. to_sna_from_kgem(struct kgem *kgem)
  352. {
  353.         return container_of(kgem, struct sna, kgem);
  354. }
  355.  
  356. #ifndef ARRAY_SIZE
  357. #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
  358. #endif
  359.  
  360. #ifndef ALIGN
  361. #define ALIGN(i,m)      (((i) + (m) - 1) & ~((m) - 1))
  362. #endif
  363.  
  364. #ifndef MIN
  365. #define MIN(a,b)        ((a) <= (b) ? (a) : (b))
  366. #endif
  367.  
  368. #ifndef MAX
  369. #define MAX(a,b)        ((a) >= (b) ? (a) : (b))
  370. #endif
  371. #endif /* _SNA_H */
  372.