nouveau_copy85b5.c revision fda9279d
1/*
2 * Copyright 2014 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs <bskeggs@redhat.com>
23 */
24
25#include "nouveau_copy.h"
26
27#include "hwdefs/nv_object.xml.h"
28#include "nv50_accel.h"
29
30static Bool
31nouveau_copy85b5_rect(struct nouveau_pushbuf *push, struct nouveau_object *copy,
32		      int w, int h, int cpp,
33		      struct nouveau_bo *src, uint32_t src_off, int src_dom,
34		      int src_pitch, int src_h, int src_x, int src_y,
35		      struct nouveau_bo *dst, uint32_t dst_off, int dst_dom,
36		      int dst_pitch, int dst_h, int dst_x, int dst_y)
37{
38	struct nouveau_pushbuf_refn refs[] = {
39		{ src, src_dom | NOUVEAU_BO_RD },
40		{ dst, dst_dom | NOUVEAU_BO_WR },
41	};
42	unsigned exec;
43
44	if (nouveau_pushbuf_space(push, 64, 0, 0) ||
45	    nouveau_pushbuf_refn (push, refs, 2))
46		return FALSE;
47
48	exec = 0x00000000;
49	if (!src->config.nv50.memtype) {
50		src_off += src_y * src_pitch + src_x * cpp;
51		exec |= 0x00000010;
52	}
53	if (!dst->config.nv50.memtype) {
54		dst_off += dst_y * dst_pitch + dst_x * cpp;
55		exec |= 0x00000100;
56	}
57
58	BEGIN_NV04(push, SUBC_COPY(0x0200), 7);
59	PUSH_DATA (push, src->config.nv50.tile_mode);
60	PUSH_DATA (push, src_pitch);
61	PUSH_DATA (push, src_h);
62	PUSH_DATA (push, 1);
63	PUSH_DATA (push, 0);
64	PUSH_DATA (push, src_x * cpp);
65	PUSH_DATA (push, src_y);
66	BEGIN_NV04(push, SUBC_COPY(0x0220), 7);
67	PUSH_DATA (push, dst->config.nv50.tile_mode);
68	PUSH_DATA (push, dst_pitch);
69	PUSH_DATA (push, dst_h);
70	PUSH_DATA (push, 1);
71	PUSH_DATA (push, 0);
72	PUSH_DATA (push, dst_x * cpp);
73	PUSH_DATA (push, dst_y);
74	BEGIN_NV04(push, SUBC_COPY(0x030c), 8);
75	PUSH_DATA (push, (src->offset + src_off) >> 32);
76	PUSH_DATA (push, (src->offset + src_off));
77	PUSH_DATA (push, (dst->offset + dst_off) >> 32);
78	PUSH_DATA (push, (dst->offset + dst_off));
79	PUSH_DATA (push, src_pitch);
80	PUSH_DATA (push, dst_pitch);
81	PUSH_DATA (push, w * cpp);
82	PUSH_DATA (push, h);
83	BEGIN_NV04(push, SUBC_COPY(0x0300), 1);
84	PUSH_DATA (push, exec);
85	return TRUE;
86}
87
88Bool
89nouveau_copy85b5_init(NVPtr pNv)
90{
91	struct nouveau_pushbuf *push = pNv->ce_pushbuf;
92	struct nv04_fifo *fifo = pNv->ce_channel->data;
93	if (PUSH_SPACE(push, 8)) {
94		BEGIN_NV04(push, NV01_SUBC(COPY, OBJECT), 1);
95		PUSH_DATA (push, pNv->NvCopy->handle);
96		BEGIN_NV04(push, SUBC_COPY(0x0180), 3);
97		PUSH_DATA (push, fifo->vram);
98		PUSH_DATA (push, fifo->vram);
99		PUSH_DATA (push, fifo->vram);
100		pNv->ce_rect = nouveau_copy85b5_rect;
101		return TRUE;
102	}
103	return FALSE;
104}
105