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