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-uapi/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 19static inline uint32_t 20PUSH_AVAIL(struct nouveau_pushbuf *push) 21{ 22 return push->end - push->cur; 23} 24 25static inline bool 26PUSH_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 35static inline void 36PUSH_DATA(struct nouveau_pushbuf *push, uint32_t data) 37{ 38 *push->cur++ = data; 39} 40 41static inline void 42PUSH_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 48static inline void 49PUSH_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 56static inline void 57PUSH_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 66static inline uint32_t 67nouveau_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 83extern struct nouveau_screen * 84nv30_screen_create(struct nouveau_device *); 85 86extern struct nouveau_screen * 87nv50_screen_create(struct nouveau_device *); 88 89extern struct nouveau_screen * 90nvc0_screen_create(struct nouveau_device *); 91 92#endif 93