nouveau_copya0b5.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 "nvc0_accel.h"
29
30Bool
31nouveau_copya0b5_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 = 0x00000206;
49	if (!src->config.nvc0.memtype) {
50		src_off += src_y * src_pitch + src_x * cpp;
51		exec |= 0x00000080;
52	}
53	if (!dst->config.nvc0.memtype) {
54		dst_off += dst_y * dst_pitch + dst_x * cpp;
55		exec |= 0x00000100;
56	}
57
58	BEGIN_NVC0(push, SUBC_COPY(0x0728), 6);
59	PUSH_DATA (push, 0x00001000 | src->config.nvc0.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_y << 16) | src_x * cpp);
65	BEGIN_NVC0(push, SUBC_COPY(0x070c), 6);
66	PUSH_DATA (push, 0x000001000 | dst->config.nvc0.tile_mode);
67	PUSH_DATA (push, dst_pitch);
68	PUSH_DATA (push, dst_h);
69	PUSH_DATA (push, 1);
70	PUSH_DATA (push, 0);
71	PUSH_DATA (push, (dst_y << 16) | dst_x * cpp);
72	BEGIN_NVC0(push, SUBC_COPY(0x0400), 8);
73	PUSH_DATA (push, (src->offset + src_off) >> 32);
74	PUSH_DATA (push, (src->offset + src_off));
75	PUSH_DATA (push, (dst->offset + dst_off) >> 32);
76	PUSH_DATA (push, (dst->offset + dst_off));
77	PUSH_DATA (push, src_pitch);
78	PUSH_DATA (push, dst_pitch);
79	PUSH_DATA (push, w * cpp);
80	PUSH_DATA (push, h);
81	BEGIN_NVC0(push, SUBC_COPY(0x0300), 1);
82	PUSH_DATA (push, exec);
83	return TRUE;
84}
85
86Bool
87nouveau_copya0b5_init(NVPtr pNv)
88{
89	struct nouveau_pushbuf *push = pNv->ce_pushbuf;
90	if (PUSH_SPACE(push, 8)) {
91		BEGIN_NVC0(push, NV01_SUBC(COPY, OBJECT), 1);
92		PUSH_DATA (push, pNv->NvCopy->handle);
93		pNv->ce_rect = nouveau_copya0b5_rect;
94		return TRUE;
95	}
96	return FALSE;
97}
98