14a49301eSmrg#ifndef NOUVEAU_WINSYS_H
24a49301eSmrg#define NOUVEAU_WINSYS_H
34a49301eSmrg
44a49301eSmrg#include <stdint.h>
5af69d88dSmrg#include <inttypes.h>
6af69d88dSmrg
74a49301eSmrg#include "pipe/p_defines.h"
84a49301eSmrg
99f464c52Smaya#include "drm-uapi/drm.h"
10af69d88dSmrg#include <nouveau.h>
114a49301eSmrg
123464ebd5Sriastradh#ifndef NV04_PFIFO_MAX_PACKET_LEN
133464ebd5Sriastradh#define NV04_PFIFO_MAX_PACKET_LEN 2047
143464ebd5Sriastradh#endif
154a49301eSmrg
16af69d88dSmrg#define NOUVEAU_MIN_BUFFER_MAP_ALIGN      64
17af69d88dSmrg#define NOUVEAU_MIN_BUFFER_MAP_ALIGN_MASK (NOUVEAU_MIN_BUFFER_MAP_ALIGN - 1)
18af69d88dSmrg
1901e04c3fSmrgstatic inline uint32_t
20af69d88dSmrgPUSH_AVAIL(struct nouveau_pushbuf *push)
21af69d88dSmrg{
22af69d88dSmrg   return push->end - push->cur;
23af69d88dSmrg}
24af69d88dSmrg
2501e04c3fSmrgstatic inline bool
26af69d88dSmrgPUSH_SPACE(struct nouveau_pushbuf *push, uint32_t size)
27af69d88dSmrg{
2801e04c3fSmrg   /* Provide a buffer so that fences always have room to be emitted */
2901e04c3fSmrg   size += 8;
30af69d88dSmrg   if (PUSH_AVAIL(push) < size)
31af69d88dSmrg      return nouveau_pushbuf_space(push, size, 0, 0) == 0;
3201e04c3fSmrg   return true;
33af69d88dSmrg}
34af69d88dSmrg
3501e04c3fSmrgstatic inline void
36af69d88dSmrgPUSH_DATA(struct nouveau_pushbuf *push, uint32_t data)
37af69d88dSmrg{
38af69d88dSmrg   *push->cur++ = data;
39af69d88dSmrg}
40af69d88dSmrg
4101e04c3fSmrgstatic inline void
42af69d88dSmrgPUSH_DATAp(struct nouveau_pushbuf *push, const void *data, uint32_t size)
43af69d88dSmrg{
44af69d88dSmrg   memcpy(push->cur, data, size * 4);
45af69d88dSmrg   push->cur += size;
46af69d88dSmrg}
47af69d88dSmrg
487ec681f3Smrgstatic inline void
497ec681f3SmrgPUSH_DATAb(struct nouveau_pushbuf *push, const void *data, uint32_t size)
507ec681f3Smrg{
517ec681f3Smrg   memcpy(push->cur, data, size);
527ec681f3Smrg   push->cur += DIV_ROUND_UP(size, 4);
537ec681f3Smrg}
547ec681f3Smrg
5501e04c3fSmrgstatic inline void
56af69d88dSmrgPUSH_DATAf(struct nouveau_pushbuf *push, float f)
57af69d88dSmrg{
58af69d88dSmrg   union { float f; uint32_t i; } u;
59af69d88dSmrg   u.f = f;
60af69d88dSmrg   PUSH_DATA(push, u.i);
61af69d88dSmrg}
62af69d88dSmrg
6301e04c3fSmrgstatic inline void
64af69d88dSmrgPUSH_KICK(struct nouveau_pushbuf *push)
65af69d88dSmrg{
66af69d88dSmrg   nouveau_pushbuf_kick(push, push->channel);
67af69d88dSmrg}
68af69d88dSmrg
69af69d88dSmrg
70af69d88dSmrg#define NOUVEAU_RESOURCE_FLAG_LINEAR   (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
71af69d88dSmrg#define NOUVEAU_RESOURCE_FLAG_DRV_PRIV (PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
72af69d88dSmrg
7301e04c3fSmrgstatic inline uint32_t
743464ebd5Sriastradhnouveau_screen_transfer_flags(unsigned pipe)
753464ebd5Sriastradh{
7601e04c3fSmrg   uint32_t flags = 0;
7701e04c3fSmrg
787ec681f3Smrg   if (!(pipe & PIPE_MAP_UNSYNCHRONIZED)) {
797ec681f3Smrg      if (pipe & PIPE_MAP_READ)
8001e04c3fSmrg         flags |= NOUVEAU_BO_RD;
817ec681f3Smrg      if (pipe & PIPE_MAP_WRITE)
8201e04c3fSmrg         flags |= NOUVEAU_BO_WR;
837ec681f3Smrg      if (pipe & PIPE_MAP_DONTBLOCK)
8401e04c3fSmrg         flags |= NOUVEAU_BO_NOBLOCK;
8501e04c3fSmrg   }
8601e04c3fSmrg
8701e04c3fSmrg   return flags;
883464ebd5Sriastradh}
894a49301eSmrg
9001e04c3fSmrgextern struct nouveau_screen *
91af69d88dSmrgnv30_screen_create(struct nouveau_device *);
924a49301eSmrg
9301e04c3fSmrgextern struct nouveau_screen *
94af69d88dSmrgnv50_screen_create(struct nouveau_device *);
954a49301eSmrg
9601e04c3fSmrgextern struct nouveau_screen *
97af69d88dSmrgnvc0_screen_create(struct nouveau_device *);
984a49301eSmrg
994a49301eSmrg#endif
100