2009-01-29 18:25:35 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2007 Nouveau Project
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NOUVEAU_PUSHBUF_H__
|
|
|
|
#define __NOUVEAU_PUSHBUF_H__
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "nouveau_bo.h"
|
|
|
|
#include "nouveau_grobj.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
nouveau_pushbuf_flush(struct nouveau_channel *, unsigned min);
|
|
|
|
|
2009-11-03 22:23:53 -07:00
|
|
|
int
|
|
|
|
nouveau_pushbuf_marker_emit(struct nouveau_channel *chan,
|
|
|
|
unsigned wait_dwords, unsigned wait_relocs);
|
|
|
|
|
|
|
|
void
|
|
|
|
nouveau_pushbuf_marker_undo(struct nouveau_channel *chan);
|
|
|
|
|
2009-01-29 18:25:35 -07:00
|
|
|
int
|
|
|
|
nouveau_pushbuf_emit_reloc(struct nouveau_channel *, void *ptr,
|
2009-06-02 21:54:43 -06:00
|
|
|
struct nouveau_bo *, uint32_t data, uint32_t data2,
|
|
|
|
uint32_t flags, uint32_t vor, uint32_t tor);
|
2009-01-29 18:25:35 -07:00
|
|
|
|
2010-01-29 01:53:24 -07:00
|
|
|
int
|
|
|
|
nouveau_pushbuf_submit(struct nouveau_channel *chan, struct nouveau_bo *bo,
|
|
|
|
unsigned offset, unsigned length);
|
|
|
|
|
2009-01-29 18:25:35 -07:00
|
|
|
/* Push buffer access macros */
|
2009-11-03 22:23:53 -07:00
|
|
|
static __inline__ int
|
|
|
|
MARK_RING(struct nouveau_channel *chan, unsigned dwords, unsigned relocs)
|
|
|
|
{
|
|
|
|
return nouveau_pushbuf_marker_emit(chan, dwords, relocs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
|
|
|
MARK_UNDO(struct nouveau_channel *chan)
|
|
|
|
{
|
|
|
|
nouveau_pushbuf_marker_undo(chan);
|
|
|
|
}
|
|
|
|
|
2009-01-29 18:25:35 -07:00
|
|
|
static __inline__ void
|
|
|
|
OUT_RING(struct nouveau_channel *chan, unsigned data)
|
|
|
|
{
|
2010-01-29 01:53:24 -07:00
|
|
|
*(chan->cur++) = (data);
|
2009-01-29 18:25:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
|
|
|
OUT_RINGp(struct nouveau_channel *chan, const void *data, unsigned size)
|
|
|
|
{
|
2010-01-29 01:53:24 -07:00
|
|
|
memcpy(chan->cur, data, size * 4);
|
|
|
|
chan->cur += size;
|
2009-01-29 18:25:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
|
|
|
OUT_RINGf(struct nouveau_channel *chan, float f)
|
|
|
|
{
|
|
|
|
union { uint32_t i; float f; } c;
|
|
|
|
c.f = f;
|
|
|
|
OUT_RING(chan, c.i);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ unsigned
|
|
|
|
AVAIL_RING(struct nouveau_channel *chan)
|
|
|
|
{
|
2010-01-29 01:53:24 -07:00
|
|
|
return chan->end - chan->cur;
|
2009-01-29 18:25:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
|
|
|
WAIT_RING(struct nouveau_channel *chan, unsigned size)
|
|
|
|
{
|
2010-01-29 01:53:24 -07:00
|
|
|
if (chan->cur + size > chan->end)
|
2009-01-29 18:25:35 -07:00
|
|
|
nouveau_pushbuf_flush(chan, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
|
|
|
FIRE_RING(struct nouveau_channel *chan)
|
|
|
|
{
|
|
|
|
nouveau_pushbuf_flush(chan, 0);
|
|
|
|
}
|
|
|
|
|
2009-11-03 22:23:53 -07:00
|
|
|
static __inline__ int
|
2009-01-29 18:25:35 -07:00
|
|
|
OUT_RELOC(struct nouveau_channel *chan, struct nouveau_bo *bo,
|
|
|
|
unsigned data, unsigned flags, unsigned vor, unsigned tor)
|
|
|
|
{
|
2010-01-29 01:53:24 -07:00
|
|
|
return nouveau_pushbuf_emit_reloc(chan, chan->cur++, bo,
|
2009-11-03 22:23:53 -07:00
|
|
|
data, 0, flags, vor, tor);
|
2009-06-02 21:54:43 -06:00
|
|
|
}
|
|
|
|
|
2009-11-03 22:23:53 -07:00
|
|
|
static __inline__ int
|
2009-06-02 21:54:43 -06:00
|
|
|
OUT_RELOC2(struct nouveau_channel *chan, struct nouveau_bo *bo,
|
|
|
|
unsigned data, unsigned data2, unsigned flags,
|
|
|
|
unsigned vor, unsigned tor)
|
|
|
|
{
|
2010-01-29 01:53:24 -07:00
|
|
|
return nouveau_pushbuf_emit_reloc(chan, chan->cur++, bo,
|
2009-11-03 22:23:53 -07:00
|
|
|
data, data2, flags, vor, tor);
|
2009-01-29 18:25:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Raw data + flags depending on FB/TT buffer */
|
2009-11-03 22:23:53 -07:00
|
|
|
static __inline__ int
|
2009-01-29 18:25:35 -07:00
|
|
|
OUT_RELOCd(struct nouveau_channel *chan, struct nouveau_bo *bo,
|
|
|
|
unsigned data, unsigned flags, unsigned vor, unsigned tor)
|
|
|
|
{
|
2009-11-03 22:23:53 -07:00
|
|
|
return OUT_RELOC(chan, bo, data, flags | NOUVEAU_BO_OR, vor, tor);
|
2009-01-29 18:25:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FB/TT object handle */
|
2009-11-03 22:23:53 -07:00
|
|
|
static __inline__ int
|
2009-01-29 18:25:35 -07:00
|
|
|
OUT_RELOCo(struct nouveau_channel *chan, struct nouveau_bo *bo,
|
|
|
|
unsigned flags)
|
|
|
|
{
|
2009-11-03 22:23:53 -07:00
|
|
|
return OUT_RELOC(chan, bo, 0, flags | NOUVEAU_BO_OR,
|
|
|
|
chan->vram->handle, chan->gart->handle);
|
2009-01-29 18:25:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Low 32-bits of offset */
|
2009-11-03 22:23:53 -07:00
|
|
|
static __inline__ int
|
2009-01-29 18:25:35 -07:00
|
|
|
OUT_RELOCl(struct nouveau_channel *chan, struct nouveau_bo *bo,
|
|
|
|
unsigned delta, unsigned flags)
|
|
|
|
{
|
2009-11-03 22:23:53 -07:00
|
|
|
return OUT_RELOC(chan, bo, delta, flags | NOUVEAU_BO_LOW, 0, 0);
|
2009-01-29 18:25:35 -07:00
|
|
|
}
|
|
|
|
|
2009-06-02 21:54:43 -06:00
|
|
|
/* Low 32-bits of offset + GPU linear access range info */
|
2009-11-03 22:23:53 -07:00
|
|
|
static __inline__ int
|
2009-06-02 21:54:43 -06:00
|
|
|
OUT_RELOCr(struct nouveau_channel *chan, struct nouveau_bo *bo,
|
|
|
|
unsigned delta, unsigned size, unsigned flags)
|
|
|
|
{
|
2009-11-03 22:23:53 -07:00
|
|
|
return OUT_RELOC2(chan, bo, delta, size, flags | NOUVEAU_BO_LOW, 0, 0);
|
2009-06-02 21:54:43 -06:00
|
|
|
}
|
|
|
|
|
2009-01-29 18:25:35 -07:00
|
|
|
/* High 32-bits of offset */
|
2009-11-03 22:23:53 -07:00
|
|
|
static __inline__ int
|
2009-01-29 18:25:35 -07:00
|
|
|
OUT_RELOCh(struct nouveau_channel *chan, struct nouveau_bo *bo,
|
|
|
|
unsigned delta, unsigned flags)
|
|
|
|
{
|
2009-11-03 22:23:53 -07:00
|
|
|
return OUT_RELOC(chan, bo, delta, flags | NOUVEAU_BO_HIGH, 0, 0);
|
2009-01-29 18:25:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|