nouveau_copy90b5.c revision fda9279d
11.3Sjoerg/*
21.2Smartin * Copyright 2014 Red Hat Inc.
31.2Smartin *
41.2Smartin * Permission is hereby granted, free of charge, to any person obtaining a
51.2Smartin * copy of this software and associated documentation files (the "Software"),
61.2Smartin * to deal in the Software without restriction, including without limitation
71.2Smartin * the rights to use, copy, modify, merge, publish, distribute, sublicense,
81.2Smartin * and/or sell copies of the Software, and to permit persons to whom the
91.2Smartin * Software is furnished to do so, subject to the following conditions:
101.2Smartin *
111.2Smartin * The above copyright notice and this permission notice shall be included in
121.2Smartin * all copies or substantial portions of the Software.
131.2Smartin *
141.2Smartin * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
151.2Smartin * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
161.2Smartin * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
171.2Smartin * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
181.2Smartin * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
191.2Smartin * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
201.2Smartin * OTHER DEALINGS IN THE SOFTWARE.
211.2Smartin *
221.2Smartin * Authors: Ben Skeggs <bskeggs@redhat.com>
231.2Smartin */
241.2Smartin
251.2Smartin#include "nouveau_copy.h"
261.2Smartin
271.2Smartin#include "hwdefs/nv_object.xml.h"
281.2Smartin#include "nvc0_accel.h"
291.2Smartin
301.2Smartinstatic Bool
311.2Smartinnouveau_copy90b5_rect(struct nouveau_pushbuf *push, struct nouveau_object *copy,
321.2Smartin		      int w, int h, int cpp,
331.2Smartin		      struct nouveau_bo *src, uint32_t src_off, int src_dom,
341.2Smartin		      int src_pitch, int src_h, int src_x, int src_y,
351.2Smartin		      struct nouveau_bo *dst, uint32_t dst_off, int dst_dom,
361.2Smartin		      int dst_pitch, int dst_h, int dst_x, int dst_y)
371.2Smartin{
381.2Smartin	struct nouveau_pushbuf_refn refs[] = {
391.2Smartin		{ src, src_dom | NOUVEAU_BO_RD },
401.2Smartin		{ dst, dst_dom | NOUVEAU_BO_WR },
411.2Smartin	};
421.2Smartin	unsigned exec;
431.2Smartin
441.2Smartin	if (nouveau_pushbuf_space(push, 64, 0, 0) ||
451.2Smartin	    nouveau_pushbuf_refn (push, refs, 2))
461.2Smartin		return FALSE;
471.2Smartin
481.2Smartin	exec = 0x00000000;
491.2Smartin	if (!src->config.nvc0.memtype) {
501.2Smartin		src_off += src_y * src_pitch + src_x * cpp;
511.2Smartin		exec |= 0x00000010;
521.2Smartin	}
531.2Smartin	if (!dst->config.nvc0.memtype) {
541.2Smartin		dst_off += dst_y * dst_pitch + dst_x * cpp;
551.2Smartin		exec |= 0x00000100;
561.2Smartin	}
571.2Smartin
581.2Smartin	BEGIN_NVC0(push, SUBC_COPY(0x0200), 7);
591.2Smartin	PUSH_DATA (push, src->config.nvc0.tile_mode);
601.2Smartin	PUSH_DATA (push, src_pitch);
611.2Smartin	PUSH_DATA (push, src_h);
621.2Smartin	PUSH_DATA (push, 1);
631.2Smartin	PUSH_DATA (push, 0);
641.3Sjoerg	PUSH_DATA (push, src_x * cpp);
651.3Sjoerg	PUSH_DATA (push, src_y);
66	BEGIN_NVC0(push, SUBC_COPY(0x0220), 7);
67	PUSH_DATA (push, dst->config.nvc0.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_NVC0(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_NVC0(push, SUBC_COPY(0x0300), 1);
84	PUSH_DATA (push, exec);
85
86	return TRUE;
87}
88
89Bool
90nouveau_copy90b5_init(NVPtr pNv)
91{
92	struct nouveau_pushbuf *push = pNv->ce_pushbuf;
93	if (PUSH_SPACE(push, 8)) {
94		BEGIN_NVC0(push, NV01_SUBC(COPY, OBJECT), 1);
95		PUSH_DATA (push, pNv->NvCopy->handle);
96		pNv->ce_rect = nouveau_copy90b5_rect;
97		return TRUE;
98	}
99	return FALSE;
100}
101