Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | /* * Copyright 2007 Dave Airlied * All Rights Reserved. * * 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 (including the next * paragraph) 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 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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. */ /* * Authors: Dave Airlied <airlied@linux.ie> * Ben Skeggs <darktama@iinet.net.au> * Jeremy Kolb <jkolb@brandeis.edu> */ #include "nouveau_bo.h" #include "nouveau_dma.h" #include "nouveau_drv.h" #include "nouveau_mem.h" #include <nvif/push206e.h> #include <nvhw/class/cl5039.h> int nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo, struct ttm_resource *old_reg, struct ttm_resource *new_reg) { struct nouveau_mem *mem = nouveau_mem(old_reg); struct nvif_push *push = chan->chan.push; u64 length = new_reg->size; u64 src_offset = mem->vma[0].addr; u64 dst_offset = mem->vma[1].addr; int src_tiled = !!mem->kind; int dst_tiled = !!nouveau_mem(new_reg)->kind; int ret; while (length) { u32 amount, stride, height; ret = PUSH_WAIT(push, 18 + 6 * (src_tiled + dst_tiled)); if (ret) return ret; amount = min(length, (u64)(4 * 1024 * 1024)); stride = 16 * 4; height = amount / stride; if (src_tiled) { PUSH_MTHD(push, NV5039, SET_SRC_MEMORY_LAYOUT, NVDEF(NV5039, SET_SRC_MEMORY_LAYOUT, V, BLOCKLINEAR), SET_SRC_BLOCK_SIZE, NVDEF(NV5039, SET_SRC_BLOCK_SIZE, WIDTH, ONE_GOB) | NVDEF(NV5039, SET_SRC_BLOCK_SIZE, HEIGHT, ONE_GOB) | NVDEF(NV5039, SET_SRC_BLOCK_SIZE, DEPTH, ONE_GOB), SET_SRC_WIDTH, stride, SET_SRC_HEIGHT, height, SET_SRC_DEPTH, 1, SET_SRC_LAYER, 0, SET_SRC_ORIGIN, NVVAL(NV5039, SET_SRC_ORIGIN, X, 0) | NVVAL(NV5039, SET_SRC_ORIGIN, Y, 0)); } else { PUSH_MTHD(push, NV5039, SET_SRC_MEMORY_LAYOUT, NVDEF(NV5039, SET_SRC_MEMORY_LAYOUT, V, PITCH)); } if (dst_tiled) { PUSH_MTHD(push, NV5039, SET_DST_MEMORY_LAYOUT, NVDEF(NV5039, SET_DST_MEMORY_LAYOUT, V, BLOCKLINEAR), SET_DST_BLOCK_SIZE, NVDEF(NV5039, SET_DST_BLOCK_SIZE, WIDTH, ONE_GOB) | NVDEF(NV5039, SET_DST_BLOCK_SIZE, HEIGHT, ONE_GOB) | NVDEF(NV5039, SET_DST_BLOCK_SIZE, DEPTH, ONE_GOB), SET_DST_WIDTH, stride, SET_DST_HEIGHT, height, SET_DST_DEPTH, 1, SET_DST_LAYER, 0, SET_DST_ORIGIN, NVVAL(NV5039, SET_DST_ORIGIN, X, 0) | NVVAL(NV5039, SET_DST_ORIGIN, Y, 0)); } else { PUSH_MTHD(push, NV5039, SET_DST_MEMORY_LAYOUT, NVDEF(NV5039, SET_DST_MEMORY_LAYOUT, V, PITCH)); } PUSH_MTHD(push, NV5039, OFFSET_IN_UPPER, NVVAL(NV5039, OFFSET_IN_UPPER, VALUE, upper_32_bits(src_offset)), OFFSET_OUT_UPPER, NVVAL(NV5039, OFFSET_OUT_UPPER, VALUE, upper_32_bits(dst_offset))); PUSH_MTHD(push, NV5039, OFFSET_IN, lower_32_bits(src_offset), OFFSET_OUT, lower_32_bits(dst_offset), PITCH_IN, stride, PITCH_OUT, stride, LINE_LENGTH_IN, stride, LINE_COUNT, height, FORMAT, NVDEF(NV5039, FORMAT, IN, ONE) | NVDEF(NV5039, FORMAT, OUT, ONE), BUFFER_NOTIFY, NVDEF(NV5039, BUFFER_NOTIFY, TYPE, WRITE_ONLY)); PUSH_MTHD(push, NV5039, NO_OPERATION, 0x00000000); length -= amount; src_offset += amount; dst_offset += amount; } return 0; } int nv50_bo_move_init(struct nouveau_channel *chan, u32 handle) { struct nvif_push *push = chan->chan.push; int ret; ret = PUSH_WAIT(push, 6); if (ret) return ret; PUSH_MTHD(push, NV5039, SET_OBJECT, handle); PUSH_MTHD(push, NV5039, SET_CONTEXT_DMA_NOTIFY, chan->drm->ntfy.handle, SET_CONTEXT_DMA_BUFFER_IN, chan->vram.handle, SET_CONTEXT_DMA_BUFFER_OUT, chan->vram.handle); return 0; } |