1fda9279dSmrg#ifndef __NV04_ACCEL_H__
2fda9279dSmrg#define __NV04_ACCEL_H__
3fda9279dSmrg
4fda9279dSmrg#include "hwdefs/nv_object.xml.h"
5fda9279dSmrg#include "hwdefs/nv01_2d.xml.h"
6fda9279dSmrg
7fda9279dSmrg#define XV_TABLE_SIZE 512
8fda9279dSmrg
9fda9279dSmrg/* scratch buffer offsets */
10fda9279dSmrg#define PFP_PASS          0x00000000
11fda9279dSmrg#define PFP_S             0x00000100
12fda9279dSmrg#define PFP_C             0x00000200
13fda9279dSmrg#define PFP_CCA           0x00000300
14fda9279dSmrg#define PFP_CCASA         0x00000400
15fda9279dSmrg#define PFP_S_A8          0x00000500
16fda9279dSmrg#define PFP_C_A8          0x00000600
17fda9279dSmrg#define PFP_NV12_BILINEAR 0x00000700
18fda9279dSmrg#define PFP_NV12_BICUBIC  0x00000800
19fda9279dSmrg#define XV_TABLE          0x00001000
20fda9279dSmrg#define SOLID(i)         (0x00002000 + (i) * 0x100)
21fda9279dSmrg
22fda9279dSmrg/* subchannel assignments */
23fda9279dSmrg#define SUBC_M2MF(mthd)  0, (mthd)
24fda9279dSmrg#define NV03_M2MF(mthd)  SUBC_M2MF(NV03_M2MF_##mthd)
25fda9279dSmrg#define SUBC_NVSW(mthd)  1, (mthd)
26fda9279dSmrg#define SUBC_SF2D(mthd)  2, (mthd)
27fda9279dSmrg#define NV04_SF2D(mthd)  SUBC_SF2D(NV04_SURFACE_2D_##mthd)
28fda9279dSmrg#define NV10_SF2D(mthd)  SUBC_SF2D(NV10_SURFACE_2D_##mthd)
29fda9279dSmrg#define SUBC_RECT(mthd)  3, (mthd)
30fda9279dSmrg#define NV04_RECT(mthd)  SUBC_RECT(NV04_GDI_##mthd)
31fda9279dSmrg#define SUBC_BLIT(mthd)  4, (mthd)
32fda9279dSmrg#define NV01_BLIT(mthd)  SUBC_BLIT(NV01_BLIT_##mthd)
33fda9279dSmrg#define NV04_BLIT(mthd)  SUBC_BLIT(NV04_BLIT_##mthd)
34fda9279dSmrg#define NV15_BLIT(mthd)  SUBC_BLIT(NV15_BLIT_##mthd)
35fda9279dSmrg#define SUBC_IFC(mthd)   5, (mthd)
36fda9279dSmrg#define NV01_IFC(mthd)   SUBC_IFC(NV01_IFC_##mthd)
37fda9279dSmrg#define NV04_IFC(mthd)   SUBC_IFC(NV04_IFC_##mthd)
38fda9279dSmrg#define SUBC_MISC(mthd)  6, (mthd)
39fda9279dSmrg#define NV03_SIFM(mthd)  SUBC_MISC(NV03_SIFM_##mthd)
40fda9279dSmrg#define NV05_SIFM(mthd)  SUBC_MISC(NV05_SIFM_##mthd)
41fda9279dSmrg#define NV01_BETA(mthd)  SUBC_MISC(NV01_BETA_##mthd)
42fda9279dSmrg#define NV04_BETA4(mthd) SUBC_MISC(NV04_BETA4_##mthd)
43fda9279dSmrg#define NV01_PATT(mthd)  SUBC_MISC(NV01_PATTERN_##mthd)
44fda9279dSmrg#define NV04_PATT(mthd)  SUBC_MISC(NV04_PATTERN_##mthd)
45fda9279dSmrg#define NV01_ROP(mthd)   SUBC_MISC(NV01_ROP_##mthd)
46fda9279dSmrg#define NV01_CLIP(mthd)  SUBC_MISC(NV01_CLIP_##mthd)
47fda9279dSmrg#define SUBC_3D(mthd)    7, (mthd)
48fda9279dSmrg#define NV10_3D(mthd)    SUBC_3D(NV10_3D_##mthd)
49fda9279dSmrg#define NV30_3D(mthd)    SUBC_3D(NV30_3D_##mthd)
50fda9279dSmrg#define NV40_3D(mthd)    SUBC_3D(NV40_3D_##mthd)
51fda9279dSmrg
52fda9279dSmrgstatic __inline__ void
53fda9279dSmrgPUSH_DATAu(struct nouveau_pushbuf *push, struct nouveau_bo *bo,
54fda9279dSmrg	   unsigned delta, unsigned dwords)
55fda9279dSmrg{
56fda9279dSmrg	const uint32_t domain = NOUVEAU_BO_VRAM | NOUVEAU_BO_WR;
57fda9279dSmrg	struct nouveau_pushbuf_refn refs[] = { { bo, domain } };
58fda9279dSmrg	unsigned pitch = ((dwords * 4) + 63) & ~63;
59fda9279dSmrg
60fda9279dSmrg	if (nouveau_pushbuf_space(push, 32 + dwords, 2, 0) ||
61fda9279dSmrg	    nouveau_pushbuf_refn (push, refs, 1))
62fda9279dSmrg		return;
63fda9279dSmrg
64fda9279dSmrg	BEGIN_NV04(push, NV01_SUBC(MISC, OBJECT), 1);
65fda9279dSmrg	PUSH_DATA (push, NvClipRectangle);
66fda9279dSmrg	BEGIN_NV04(push, NV01_CLIP(POINT), 2);
67fda9279dSmrg	PUSH_DATA (push, (0 << 16) | 0);
68fda9279dSmrg	PUSH_DATA (push, (1 << 16) | dwords);
69fda9279dSmrg	BEGIN_NV04(push, NV04_SF2D(FORMAT), 4);
70fda9279dSmrg	PUSH_DATA (push, NV04_SURFACE_2D_FORMAT_A8R8G8B8);
71fda9279dSmrg	PUSH_DATA (push, (pitch << 16) | pitch);
72fda9279dSmrg	PUSH_RELOC(push, bo, delta, NOUVEAU_BO_LOW, 0, 0);
73fda9279dSmrg	PUSH_RELOC(push, bo, delta, NOUVEAU_BO_LOW, 0, 0);
74fda9279dSmrg	BEGIN_NV04(push, NV01_IFC(OPERATION), 5);
75fda9279dSmrg	PUSH_DATA (push, NV01_IFC_OPERATION_SRCCOPY);
76fda9279dSmrg	PUSH_DATA (push, NV01_IFC_COLOR_FORMAT_A8R8G8B8);
77fda9279dSmrg	PUSH_DATA (push, (0 << 16) | 0);
78fda9279dSmrg	PUSH_DATA (push, (1 << 16) | dwords);
79fda9279dSmrg	PUSH_DATA (push, (1 << 16) | dwords);
80fda9279dSmrg	BEGIN_NV04(push, NV01_IFC(COLOR(0)), dwords);
81fda9279dSmrg}
82fda9279dSmrg
83fda9279dSmrg/* For NV40 FP upload, deal with the weird-arse big-endian swap */
84fda9279dSmrgstatic __inline__ void
85fda9279dSmrgPUSH_DATAs(struct nouveau_pushbuf *push, unsigned data)
86fda9279dSmrg{
87fda9279dSmrg#if (X_BYTE_ORDER != X_LITTLE_ENDIAN)
88fda9279dSmrg	data = (data >> 16) | ((data & 0xffff) << 16);
89fda9279dSmrg#endif
90fda9279dSmrg	PUSH_DATA(push, data);
91fda9279dSmrg}
92fda9279dSmrg
93fda9279dSmrg#endif
94