diff options
Diffstat (limited to 'radeon_device.h')
-rw-r--r-- | radeon_device.h | 101 |
1 files changed, 84 insertions, 17 deletions
diff --git a/radeon_device.h b/radeon_device.h index 94f6495..cd623b3 100644 --- a/radeon_device.h +++ b/radeon_device.h @@ -17,43 +17,110 @@ #ifndef RADEON_DEVICE_H #define RADEON_DEVICE_H +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include "xf86drm.h" +#include "radeon_bo.h" +#include "radeon_drm.h" #include "radeon.h" -#include "lwrapper.h" -#include "radeon_atom.h" +#include "list.h" +#include "r600_atom.h" -struct radeon_device; -struct radeon_ib; -struct radeon_atom; +/* UTILITIES END ************************************************************/ +#define GFP_KERNEL 0 +#define kmalloc(s, gfp) malloc(s) +#define kfree(p) free(p) +#define dev_err(d, p, args...) fprintf(stderr, p, ##args) + +struct kref { + int refcount; +}; -/* Wrapper to make it looks like kernel *************************************/ +void kref_set(struct kref *kref, int num); +void kref_init(struct kref *kref); +void kref_get(struct kref *kref); +int kref_put(struct kref *kref, void (*release) (struct kref *kref)); +/** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) #define radeon_bo_size(bo) ((bo)->size) +/* UTILITIES END ************************************************************/ + +struct radeon_device; + +struct radeon_ib { + u32 *ptr; + u32 cpkts; + u32 length_dw; + u32 *relocs; + u32 crelocs; + u32 nrelocs; +}; + +struct radeon_atom_flush { + struct list_head list; + u32 flags; + struct radeon_bo *bo; +}; + +typedef int (*radeon_atom_emit_t)(struct radeon_device*, + struct radeon_atom*, + void *data, + struct radeon_ib*); + +struct radeon_atom { + struct list_head list; + struct kref kref; + u32 type; + u32 id; + u32 nflushes; + u32 npkts; + u32 nbo; + u32 pkts[256]; + struct radeon_bo *bo[32]; + u32 flags[32]; + void *state; + radeon_atom_emit_t emit; +}; + struct radeon_device { struct radeon *radeon; int fd; struct radeon_bo *bo[32]; u32 nbo; - struct idr idr; - struct mutex mutex; struct r600_batches batches; unsigned npipes; unsigned nbanks; unsigned group_bytes; }; -struct radeon_ib { - u32 *ptr; - u32 cpkts; - u32 length_dw; - u32 *relocs; - u32 crelocs; - u32 nrelocs; -}; - extern u32 radeon_ib_reloc(struct radeon_ib *ib, struct radeon_bo *bo, u32 d); extern int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib); extern void radeon_ib_free(struct radeon_ib *ib); extern int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib); +extern int radeon_atom_init(struct radeon_atom *atom, radeon_atom_emit_t emit); +extern void radeon_atom_flush_cleanup(struct list_head *flushes); +extern int radeon_atom_flush_add(struct list_head *flushes, struct radeon_bo *bo, u32 flags); +extern int radeon_atom_emit_default(struct radeon_device *rdev, struct radeon_atom *atom, + void *data, struct radeon_ib *ib); +extern void radeon_atom_release(struct kref *kref); +extern void radeon_device_set_bo_list(struct radeon_device *rdev, u32 nbo, struct radeon_bo **bo); +extern struct radeon_bo *radeon_bo_lookup(struct radeon_device *rdev, u32 handle); + +static inline void radeon_atom_put(struct radeon_atom *atom) +{ + kref_put(&atom->kref, radeon_atom_release); +} static inline int radeon_ib_begin(struct radeon_ib *ib, u32 ndw) { |