Ben Skeggs | 8d5a8eb | 2007-08-06 22:32:36 +1000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2007 Ben Skeggs. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining |
| 6 | * a copy of this software and associated documentation files (the |
| 7 | * "Software"), to deal in the Software without restriction, including |
| 8 | * without limitation the rights to use, copy, modify, merge, publish, |
| 9 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 10 | * permit persons to whom the Software is furnished to do so, subject to |
| 11 | * the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice (including the |
| 14 | * next paragraph) shall be included in all copies or substantial |
| 15 | * portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 | * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE |
| 21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #ifndef __NOUVEAU_DMA_H__ |
| 28 | #define __NOUVEAU_DMA_H__ |
| 29 | |
| 30 | typedef enum { |
| 31 | NvSubM2MF = 0, |
| 32 | } nouveau_subchannel_id_t; |
| 33 | |
| 34 | typedef enum { |
| 35 | NvM2MF = 0x80039001, |
| 36 | NvDmaFB = 0x8003d001, |
| 37 | NvDmaTT = 0x8003d002, |
| 38 | NvNotify0 = 0x8003d003 |
| 39 | } nouveau_object_handle_t; |
| 40 | |
| 41 | #define NV_MEMORY_TO_MEMORY_FORMAT 0x00000039 |
| 42 | #define NV_MEMORY_TO_MEMORY_FORMAT_NAME 0x00000000 |
| 43 | #define NV_MEMORY_TO_MEMORY_FORMAT_SET_REF 0x00000050 |
| 44 | #define NV_MEMORY_TO_MEMORY_FORMAT_NOP 0x00000100 |
| 45 | #define NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY 0x00000104 |
| 46 | #define NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY_STYLE_WRITE 0x00000000 |
| 47 | #define NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY_STYLE_WRITE_LE_AWAKEN 0x00000001 |
| 48 | #define NV_MEMORY_TO_MEMORY_FORMAT_SET_DMA_NOTIFY 0x00000180 |
| 49 | #define NV_MEMORY_TO_MEMORY_FORMAT_SET_DMA_SOURCE 0x00000184 |
| 50 | #define NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN 0x0000030c |
| 51 | |
| 52 | #define NV50_MEMORY_TO_MEMORY_FORMAT 0x00005039 |
| 53 | #define NV50_MEMORY_TO_MEMORY_FORMAT_UNK200 0x00000200 |
| 54 | #define NV50_MEMORY_TO_MEMORY_FORMAT_UNK21C 0x0000021c |
| 55 | #define NV50_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN_HIGH 0x00000238 |
| 56 | #define NV50_MEMORY_TO_MEMORY_FORMAT_OFFSET_OUT_HIGH 0x0000023c |
| 57 | |
| 58 | #define BEGIN_RING(subc, mthd, cnt) do { \ |
| 59 | int push_size = (cnt) + 1; \ |
| 60 | if (dchan->push_free) { \ |
| 61 | DRM_ERROR("prior packet incomplete: %d\n", dchan->push_free); \ |
| 62 | break; \ |
| 63 | } \ |
| 64 | if (dchan->free < push_size) { \ |
| 65 | if (nouveau_dma_wait(dev, push_size)) { \ |
| 66 | DRM_ERROR("FIFO timeout\n"); \ |
| 67 | break; \ |
| 68 | } \ |
| 69 | } \ |
| 70 | dchan->free -= push_size; \ |
| 71 | dchan->push_free = push_size; \ |
| 72 | OUT_RING(((cnt)<<18) | ((subc)<<15) | mthd); \ |
| 73 | } while(0) |
| 74 | |
| 75 | #define OUT_RING(data) do { \ |
| 76 | if (dchan->push_free == 0) { \ |
| 77 | DRM_ERROR("no space left in packet\n"); \ |
| 78 | break; \ |
| 79 | } \ |
| 80 | dchan->pushbuf[dchan->cur++] = (data); \ |
| 81 | dchan->push_free--; \ |
| 82 | } while(0) |
| 83 | |
| 84 | #define FIRE_RING() do { \ |
| 85 | if (dchan->push_free) { \ |
| 86 | DRM_ERROR("packet incomplete: %d\n", dchan->push_free); \ |
| 87 | break; \ |
| 88 | } \ |
| 89 | if (dchan->cur != dchan->put) { \ |
| 90 | DRM_MEMORYBARRIER(); \ |
| 91 | dchan->put = dchan->cur; \ |
| 92 | NV_WRITE(NV03_FIFO_REGS_DMAPUT(dchan->chan->id), \ |
| 93 | (dchan->put<<2)); \ |
| 94 | } \ |
| 95 | } while(0) |
| 96 | |
| 97 | #endif |
| 98 | |