Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:12:16

0001 #ifndef __NOUVEAU_H__
0002 #define __NOUVEAU_H__
0003 
0004 #include <stdint.h>
0005 #include <stdbool.h>
0006 
0007 /* Supported class information, provided by the kernel */
0008 struct nouveau_sclass {
0009     int32_t oclass;
0010     int minver;
0011     int maxver;
0012 };
0013 
0014 /* Client-provided array describing class versions that are desired.
0015  *
0016  * These are used to match against the kernel's list of supported classes.
0017  */
0018 struct nouveau_mclass {
0019     int32_t oclass;
0020     int version;
0021     void *data;
0022 };
0023 
0024 struct nouveau_object {
0025     struct nouveau_object *parent;
0026     uint64_t handle;
0027     uint32_t oclass;
0028     uint32_t length;    /* deprecated */
0029     void *data;     /* deprecated */
0030 };
0031 
0032 int nouveau_object_new(struct nouveau_object *parent, uint64_t handle,
0033                uint32_t oclass, void *data, uint32_t length,
0034                struct nouveau_object **);
0035 void nouveau_object_del(struct nouveau_object **);
0036 int nouveau_object_mthd(struct nouveau_object *, uint32_t mthd,
0037             void *data, uint32_t size);
0038 int nouveau_object_sclass_get(struct nouveau_object *,
0039                   struct nouveau_sclass **);
0040 void nouveau_object_sclass_put(struct nouveau_sclass **);
0041 int nouveau_object_mclass(struct nouveau_object *,
0042               const struct nouveau_mclass *);
0043 
0044 struct nouveau_drm {
0045     struct nouveau_object client;
0046     int fd;
0047     uint32_t version;
0048     bool nvif;
0049 };
0050 
0051 static inline struct nouveau_drm *
0052 nouveau_drm(struct nouveau_object *obj)
0053 {
0054     while (obj && obj->parent)
0055         obj = obj->parent;
0056     return (struct nouveau_drm *)obj;
0057 }
0058 
0059 int nouveau_drm_new(int fd, struct nouveau_drm **);
0060 void nouveau_drm_del(struct nouveau_drm **);
0061 
0062 struct nouveau_device {
0063     struct nouveau_object object;
0064     int fd;         /* deprecated */
0065     uint32_t lib_version;   /* deprecated */
0066     uint32_t drm_version;   /* deprecated */
0067     uint32_t chipset;
0068     uint64_t vram_size;
0069     uint64_t gart_size;
0070     uint64_t vram_limit;
0071     uint64_t gart_limit;
0072 };
0073 
0074 int nouveau_device_new(struct nouveau_object *parent, int32_t oclass,
0075                void *data, uint32_t size, struct nouveau_device **);
0076 void nouveau_device_del(struct nouveau_device **);
0077 
0078 int nouveau_getparam(struct nouveau_device *, uint64_t param, uint64_t *value);
0079 int nouveau_setparam(struct nouveau_device *, uint64_t param, uint64_t value);
0080 
0081 /* deprecated */
0082 int nouveau_device_wrap(int fd, int close, struct nouveau_device **);
0083 int nouveau_device_open(const char *busid, struct nouveau_device **);
0084 
0085 struct nouveau_client {
0086     struct nouveau_device *device;
0087     int id;
0088 };
0089 
0090 int nouveau_client_new(struct nouveau_device *, struct nouveau_client **);
0091 void nouveau_client_del(struct nouveau_client **);
0092 
0093 union nouveau_bo_config {
0094     struct {
0095 #define NV04_BO_16BPP 0x00000001
0096 #define NV04_BO_32BPP 0x00000002
0097 #define NV04_BO_ZETA  0x00000004
0098         uint32_t surf_flags;
0099         uint32_t surf_pitch;
0100     } nv04;
0101     struct {
0102         uint32_t memtype;
0103         uint32_t tile_mode;
0104     } nv50;
0105     struct {
0106         uint32_t memtype;
0107         uint32_t tile_mode;
0108     } nvc0;
0109     uint32_t data[8];
0110 };
0111 
0112 #define NOUVEAU_BO_VRAM    0x00000001
0113 #define NOUVEAU_BO_GART    0x00000002
0114 #define NOUVEAU_BO_APER   (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)
0115 #define NOUVEAU_BO_RD      0x00000100
0116 #define NOUVEAU_BO_WR      0x00000200
0117 #define NOUVEAU_BO_RDWR   (NOUVEAU_BO_RD | NOUVEAU_BO_WR)
0118 #define NOUVEAU_BO_NOBLOCK 0x00000400
0119 #define NOUVEAU_BO_LOW     0x00001000
0120 #define NOUVEAU_BO_HIGH    0x00002000
0121 #define NOUVEAU_BO_OR      0x00004000
0122 #define NOUVEAU_BO_MAP     0x80000000
0123 #define NOUVEAU_BO_CONTIG  0x40000000
0124 #define NOUVEAU_BO_NOSNOOP 0x20000000
0125 #define NOUVEAU_BO_COHERENT 0x10000000
0126 
0127 struct nouveau_bo {
0128     struct nouveau_device *device;
0129     uint32_t handle;
0130     uint64_t size;
0131     uint32_t flags;
0132     uint64_t offset;
0133     void *map;
0134     union nouveau_bo_config config;
0135 };
0136 
0137 int nouveau_bo_new(struct nouveau_device *, uint32_t flags, uint32_t align,
0138            uint64_t size, union nouveau_bo_config *,
0139            struct nouveau_bo **);
0140 void nouveau_bo_make_global(struct nouveau_bo *);
0141 int nouveau_bo_wrap(struct nouveau_device *, uint32_t handle,
0142             struct nouveau_bo **);
0143 int nouveau_bo_name_ref(struct nouveau_device *v, uint32_t name,
0144             struct nouveau_bo **);
0145 int nouveau_bo_name_get(struct nouveau_bo *, uint32_t *name);
0146 void nouveau_bo_ref(struct nouveau_bo *, struct nouveau_bo **);
0147 int nouveau_bo_map(struct nouveau_bo *, uint32_t access,
0148            struct nouveau_client *);
0149 int nouveau_bo_wait(struct nouveau_bo *, uint32_t access,
0150             struct nouveau_client *);
0151 int nouveau_bo_prime_handle_ref(struct nouveau_device *, int prime_fd,
0152                 struct nouveau_bo **);
0153 int nouveau_bo_set_prime(struct nouveau_bo *, int *prime_fd);
0154 
0155 struct nouveau_list {
0156     struct nouveau_list *prev;
0157     struct nouveau_list *next;
0158 };
0159 
0160 struct nouveau_bufref {
0161     struct nouveau_list thead;
0162     struct nouveau_bo *bo;
0163     uint32_t packet;
0164     uint32_t flags;
0165     uint32_t data;
0166     uint32_t vor;
0167     uint32_t tor;
0168     uint32_t priv_data;
0169     void *priv;
0170 };
0171 
0172 struct nouveau_bufctx {
0173     struct nouveau_client *client;
0174     struct nouveau_list head;
0175     struct nouveau_list pending;
0176     struct nouveau_list current;
0177     int relocs;
0178 };
0179 
0180 int nouveau_bufctx_new(struct nouveau_client *, int bins,
0181                struct nouveau_bufctx **);
0182 void nouveau_bufctx_del(struct nouveau_bufctx **);
0183 struct nouveau_bufref *
0184 nouveau_bufctx_refn(struct nouveau_bufctx *, int bin,
0185             struct nouveau_bo *, uint32_t flags);
0186 struct nouveau_bufref *
0187 nouveau_bufctx_mthd(struct nouveau_bufctx *, int bin,  uint32_t packet,
0188             struct nouveau_bo *, uint64_t data, uint32_t flags,
0189             uint32_t vor, uint32_t tor);
0190 void nouveau_bufctx_reset(struct nouveau_bufctx *, int bin);
0191 
0192 struct nouveau_pushbuf_krec;
0193 struct nouveau_pushbuf {
0194     struct nouveau_client *client;
0195     struct nouveau_object *channel;
0196     struct nouveau_bufctx *bufctx;
0197     void (*kick_notify)(struct nouveau_pushbuf *);
0198     void *user_priv;
0199     uint32_t rsvd_kick;
0200     uint32_t flags;
0201     uint32_t *cur;
0202     uint32_t *end;
0203 };
0204 
0205 struct nouveau_pushbuf_refn {
0206     struct nouveau_bo *bo;
0207     uint32_t flags;
0208 };
0209 
0210 int nouveau_pushbuf_new(struct nouveau_client *, struct nouveau_object *chan,
0211             int nr, uint32_t size, bool immediate,
0212             struct nouveau_pushbuf **);
0213 void nouveau_pushbuf_del(struct nouveau_pushbuf **);
0214 int nouveau_pushbuf_space(struct nouveau_pushbuf *, uint32_t dwords,
0215               uint32_t relocs, uint32_t pushes);
0216 void nouveau_pushbuf_data(struct nouveau_pushbuf *, struct nouveau_bo *,
0217               uint64_t offset, uint64_t length);
0218 int nouveau_pushbuf_refn(struct nouveau_pushbuf *,
0219              struct nouveau_pushbuf_refn *, int nr);
0220 /* Emits a reloc into the push buffer at the current position, you *must*
0221  * have previously added the referenced buffer to a buffer context, and
0222  * validated it against the current push buffer.
0223  */
0224 void nouveau_pushbuf_reloc(struct nouveau_pushbuf *, struct nouveau_bo *,
0225                uint32_t data, uint32_t flags,
0226                uint32_t vor, uint32_t tor);
0227 int nouveau_pushbuf_validate(struct nouveau_pushbuf *);
0228 uint32_t nouveau_pushbuf_refd(struct nouveau_pushbuf *, struct nouveau_bo *);
0229 int nouveau_pushbuf_kick(struct nouveau_pushbuf *, struct nouveau_object *chan);
0230 struct nouveau_bufctx *
0231 nouveau_pushbuf_bufctx(struct nouveau_pushbuf *, struct nouveau_bufctx *);
0232 
0233 #define NOUVEAU_DEVICE_CLASS       0x80000000
0234 #define NOUVEAU_FIFO_CHANNEL_CLASS 0x80000001
0235 #define NOUVEAU_NOTIFIER_CLASS     0x80000002
0236 
0237 struct nouveau_fifo {
0238     struct nouveau_object *object;
0239     uint32_t channel;
0240     uint32_t pushbuf;
0241     uint64_t unused1[3];
0242 };
0243 
0244 struct nv04_fifo {
0245     struct nouveau_fifo base;
0246     uint32_t vram;
0247     uint32_t gart;
0248     uint32_t notify;
0249 };
0250 
0251 struct nvc0_fifo {
0252     struct nouveau_fifo base;
0253     uint32_t notify;
0254 };
0255 
0256 #define NVE0_FIFO_ENGINE_GR  0x00000001
0257 #define NVE0_FIFO_ENGINE_VP  0x00000002
0258 #define NVE0_FIFO_ENGINE_PPP 0x00000004
0259 #define NVE0_FIFO_ENGINE_BSP 0x00000008
0260 #define NVE0_FIFO_ENGINE_CE0 0x00000010
0261 #define NVE0_FIFO_ENGINE_CE1 0x00000020
0262 #define NVE0_FIFO_ENGINE_ENC 0x00000040
0263 
0264 struct nve0_fifo {
0265     struct {
0266         struct nouveau_fifo base;
0267         uint32_t notify;
0268     };
0269     uint32_t engine;
0270 };
0271 
0272 struct nv04_notify {
0273     struct nouveau_object *object;
0274     uint32_t offset;
0275     uint32_t length;
0276 };
0277 
0278 bool
0279 nouveau_check_dead_channel(struct nouveau_drm *, struct nouveau_object *chan);
0280 
0281 #endif