/* * Copyright 2010 Jerome Glisse * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * on the rights to use, copy, modify, merge, publish, distribute, sub * license, and/or sell copies of the Software, and to permit persons to whom * the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. * * Authors: * Jerome Glisse */ #ifndef R600_H #define R600_H #include #include #include #include #include "xf86drm.h" #include "radeon_bo.h" #include "radeon_drm.h" #include "r600_winsys.h" #define R600_MAX_WORK 256 struct r600_winsys; struct r600_atom; struct radeon_ib { u32 *ptr; u32 cpkts; u32 length_dw; u32 *relocs; u32 crelocs; u32 nrelocs; }; typedef int (*r600_atom_create_t)(struct r600_winsys*, struct r600_atom*, void*); typedef int (*r600_atom_emit_t)(struct r600_winsys*, struct r600_atom*, void*, struct radeon_ib*); struct r600_atom { int refcount; u32 type; u32 id; u32 nflushes; u32 npkts; u32 nbo; u32 pkts[1024]; struct radeon_bo *bo[32]; u32 flags[32]; void *state; r600_atom_emit_t emit; }; struct r600_atom_flush { u32 flags; struct radeon_bo *bo; }; struct r600_work { struct r600_atom *atoms[R600_BATCH_NATOMS]; struct r600_atom *emit_atoms[R600_BATCH_NATOMS]; u32 nemit_atoms; u32 nflush; struct r600_atom_flush flush[480]; u32 npkts; struct r600_batch drm; }; struct r600_scheduler { struct radeon_ib *ib; u32 npkts; u32 nwork; struct r600_work work[R600_MAX_WORK]; u32 last_id[R600_BATCH_NATOMS]; }; struct r600_winsys { int fd; struct radeon_bo *bo[32]; u32 nbo; struct r600_scheduler scheduler; unsigned npipes; unsigned nbanks; unsigned group_bytes; struct radeon_bo_manager *bom; }; extern void r600_atom_ref(struct r600_atom *atom); extern u32 radeon_ib_reloc(struct radeon_ib *ib, struct radeon_bo *bo, u32 d); extern int radeon_ib_get(struct r600_winsys *rdev, struct radeon_ib **ib); extern void radeon_ib_free(struct radeon_ib *ib); extern int radeon_ib_schedule(struct r600_winsys *rdev, struct radeon_ib *ib); extern int r600_atom_emit_default(struct r600_winsys *rdev, struct r600_atom *atom, void *data, struct radeon_ib *ib); extern void r600_winsys_set_bo_list(struct r600_winsys *rdev, u32 nbo, struct radeon_bo **bo); extern struct radeon_bo *radeon_bo_lookup(struct r600_winsys *rdev, u32 handle); extern u64 crc_64(void *d, size_t len); /* R700 */ extern void r700_scheduler_states_default(struct r600_winsys *rdev, struct r600_scheduler *scheduler); extern int r600_atoms_init(struct r600_winsys *rdev); extern int r600_draw_cmd_size(struct r600_batch *batch); extern int r600_draw_cmd_emit(struct radeon_ib *ib, struct r600_batch *batch); extern void r600_memcpy_bo(struct radeon_bo *bo, u32 *src, u32 size); static inline int radeon_ib_begin(struct radeon_ib *ib, u32 ndw) { if ((ib->cpkts + ndw) > ib->length_dw) return -ENOMEM; return 0; } static inline int radeon_ib_copy(struct radeon_ib *ib, u32 *pkts, u32 ndw) { if ((ib->cpkts + ndw) > ib->length_dw) { fprintf(stderr, "IB FULL !\n"); return -ENOMEM; } memcpy(&ib->ptr[ib->cpkts], pkts, ndw * 4); ib->cpkts += ndw; return 0; } #endif