1 #ifndef NOUVEAU_WINSYS_H 2 #define NOUVEAU_WINSYS_H 3 4 #include <stdint.h> 5 #include <inttypes.h> 6 7 #include "pipe/p_defines.h" 8 9 #include <drm.h> 10 #include <nouveau.h> 11 12 #ifndef NV04_PFIFO_MAX_PACKET_LEN 13 #define NV04_PFIFO_MAX_PACKET_LEN 2047 14 #endif 15 16 #define NOUVEAU_MIN_BUFFER_MAP_ALIGN 64 17 #define NOUVEAU_MIN_BUFFER_MAP_ALIGN_MASK (NOUVEAU_MIN_BUFFER_MAP_ALIGN - 1) 18 19 static inline uint32_t 20 PUSH_AVAIL(struct nouveau_pushbuf *push) 21 { 22 return push->end - push->cur; 23 } 24 25 static inline bool 26 PUSH_SPACE(struct nouveau_pushbuf *push, uint32_t size) 27 { 28 /* Provide a buffer so that fences always have room to be emitted */ 29 size += 8; 30 if (PUSH_AVAIL(push) < size) 31 return nouveau_pushbuf_space(push, size, 0, 0) == 0; 32 return true; 33 } 34 35 static inline void 36 PUSH_DATA(struct nouveau_pushbuf *push, uint32_t data) 37 { 38 *push->cur++ = data; 39 } 40 41 static inline void 42 PUSH_DATAp(struct nouveau_pushbuf *push, const void *data, uint32_t size) 43 { 44 memcpy(push->cur, data, size * 4); 45 push->cur += size; 46 } 47 48 static inline void 49 PUSH_DATAf(struct nouveau_pushbuf *push, float f) 50 { 51 union { float f; uint32_t i; } u; 52 u.f = f; 53 PUSH_DATA(push, u.i); 54 } 55 56 static inline void 57 PUSH_KICK(struct nouveau_pushbuf *push) 58 { 59 nouveau_pushbuf_kick(push, push->channel); 60 } 61 62 63 #define NOUVEAU_RESOURCE_FLAG_LINEAR (PIPE_RESOURCE_FLAG_DRV_PRIV << 0) 64 #define NOUVEAU_RESOURCE_FLAG_DRV_PRIV (PIPE_RESOURCE_FLAG_DRV_PRIV << 1) 65 66 static inline uint32_t 67 nouveau_screen_transfer_flags(unsigned pipe) 68 { 69 uint32_t flags = 0; 70 71 if (!(pipe & PIPE_TRANSFER_UNSYNCHRONIZED)) { 72 if (pipe & PIPE_TRANSFER_READ) 73 flags |= NOUVEAU_BO_RD; 74 if (pipe & PIPE_TRANSFER_WRITE) 75 flags |= NOUVEAU_BO_WR; 76 if (pipe & PIPE_TRANSFER_DONTBLOCK) 77 flags |= NOUVEAU_BO_NOBLOCK; 78 } 79 80 return flags; 81 } 82 83 extern struct nouveau_screen * 84 nv30_screen_create(struct nouveau_device *); 85 86 extern struct nouveau_screen * 87 nv50_screen_create(struct nouveau_device *); 88 89 extern struct nouveau_screen * 90 nvc0_screen_create(struct nouveau_device *); 91 92 #endif 93