1*d350ecf5Sriastradh /* $NetBSD: nouveau_nvkm_engine_disp_basenv50.c,v 1.1.1.1 2018/08/27 01:34:56 riastradh Exp $ */ 2*d350ecf5Sriastradh 3*d350ecf5Sriastradh /* 4*d350ecf5Sriastradh * Copyright 2012 Red Hat Inc. 5*d350ecf5Sriastradh * 6*d350ecf5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a 7*d350ecf5Sriastradh * copy of this software and associated documentation files (the "Software"), 8*d350ecf5Sriastradh * to deal in the Software without restriction, including without limitation 9*d350ecf5Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10*d350ecf5Sriastradh * and/or sell copies of the Software, and to permit persons to whom the 11*d350ecf5Sriastradh * Software is furnished to do so, subject to the following conditions: 12*d350ecf5Sriastradh * 13*d350ecf5Sriastradh * The above copyright notice and this permission notice shall be included in 14*d350ecf5Sriastradh * all copies or substantial portions of the Software. 15*d350ecf5Sriastradh * 16*d350ecf5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17*d350ecf5Sriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18*d350ecf5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19*d350ecf5Sriastradh * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20*d350ecf5Sriastradh * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21*d350ecf5Sriastradh * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22*d350ecf5Sriastradh * OTHER DEALINGS IN THE SOFTWARE. 23*d350ecf5Sriastradh * 24*d350ecf5Sriastradh * Authors: Ben Skeggs 25*d350ecf5Sriastradh */ 26*d350ecf5Sriastradh #include <sys/cdefs.h> 27*d350ecf5Sriastradh __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_disp_basenv50.c,v 1.1.1.1 2018/08/27 01:34:56 riastradh Exp $"); 28*d350ecf5Sriastradh 29*d350ecf5Sriastradh #include "dmacnv50.h" 30*d350ecf5Sriastradh #include "rootnv50.h" 31*d350ecf5Sriastradh 32*d350ecf5Sriastradh #include <core/client.h> 33*d350ecf5Sriastradh 34*d350ecf5Sriastradh #include <nvif/class.h> 35*d350ecf5Sriastradh #include <nvif/unpack.h> 36*d350ecf5Sriastradh 37*d350ecf5Sriastradh int 38*d350ecf5Sriastradh nv50_disp_base_new(const struct nv50_disp_dmac_func *func, 39*d350ecf5Sriastradh const struct nv50_disp_chan_mthd *mthd, 40*d350ecf5Sriastradh struct nv50_disp_root *root, int chid, 41*d350ecf5Sriastradh const struct nvkm_oclass *oclass, void *data, u32 size, 42*d350ecf5Sriastradh struct nvkm_object **pobject) 43*d350ecf5Sriastradh { 44*d350ecf5Sriastradh union { 45*d350ecf5Sriastradh struct nv50_disp_base_channel_dma_v0 v0; 46*d350ecf5Sriastradh } *args = data; 47*d350ecf5Sriastradh struct nvkm_object *parent = oclass->parent; 48*d350ecf5Sriastradh struct nv50_disp *disp = root->disp; 49*d350ecf5Sriastradh int head, ret; 50*d350ecf5Sriastradh u64 push; 51*d350ecf5Sriastradh 52*d350ecf5Sriastradh nvif_ioctl(parent, "create disp base channel dma size %d\n", size); 53*d350ecf5Sriastradh if (nvif_unpack(args->v0, 0, 0, false)) { 54*d350ecf5Sriastradh nvif_ioctl(parent, "create disp base channel dma vers %d " 55*d350ecf5Sriastradh "pushbuf %016llx head %d\n", 56*d350ecf5Sriastradh args->v0.version, args->v0.pushbuf, args->v0.head); 57*d350ecf5Sriastradh if (args->v0.head > disp->base.head.nr) 58*d350ecf5Sriastradh return -EINVAL; 59*d350ecf5Sriastradh push = args->v0.pushbuf; 60*d350ecf5Sriastradh head = args->v0.head; 61*d350ecf5Sriastradh } else 62*d350ecf5Sriastradh return ret; 63*d350ecf5Sriastradh 64*d350ecf5Sriastradh return nv50_disp_dmac_new_(func, mthd, root, chid + head, 65*d350ecf5Sriastradh head, push, oclass, pobject); 66*d350ecf5Sriastradh } 67*d350ecf5Sriastradh 68*d350ecf5Sriastradh static const struct nv50_disp_mthd_list 69*d350ecf5Sriastradh nv50_disp_base_mthd_base = { 70*d350ecf5Sriastradh .mthd = 0x0000, 71*d350ecf5Sriastradh .addr = 0x000000, 72*d350ecf5Sriastradh .data = { 73*d350ecf5Sriastradh { 0x0080, 0x000000 }, 74*d350ecf5Sriastradh { 0x0084, 0x0008c4 }, 75*d350ecf5Sriastradh { 0x0088, 0x0008d0 }, 76*d350ecf5Sriastradh { 0x008c, 0x0008dc }, 77*d350ecf5Sriastradh { 0x0090, 0x0008e4 }, 78*d350ecf5Sriastradh { 0x0094, 0x610884 }, 79*d350ecf5Sriastradh { 0x00a0, 0x6108a0 }, 80*d350ecf5Sriastradh { 0x00a4, 0x610878 }, 81*d350ecf5Sriastradh { 0x00c0, 0x61086c }, 82*d350ecf5Sriastradh { 0x00e0, 0x610858 }, 83*d350ecf5Sriastradh { 0x00e4, 0x610860 }, 84*d350ecf5Sriastradh { 0x00e8, 0x6108ac }, 85*d350ecf5Sriastradh { 0x00ec, 0x6108b4 }, 86*d350ecf5Sriastradh { 0x0100, 0x610894 }, 87*d350ecf5Sriastradh { 0x0110, 0x6108bc }, 88*d350ecf5Sriastradh { 0x0114, 0x61088c }, 89*d350ecf5Sriastradh {} 90*d350ecf5Sriastradh } 91*d350ecf5Sriastradh }; 92*d350ecf5Sriastradh 93*d350ecf5Sriastradh const struct nv50_disp_mthd_list 94*d350ecf5Sriastradh nv50_disp_base_mthd_image = { 95*d350ecf5Sriastradh .mthd = 0x0400, 96*d350ecf5Sriastradh .addr = 0x000000, 97*d350ecf5Sriastradh .data = { 98*d350ecf5Sriastradh { 0x0800, 0x6108f0 }, 99*d350ecf5Sriastradh { 0x0804, 0x6108fc }, 100*d350ecf5Sriastradh { 0x0808, 0x61090c }, 101*d350ecf5Sriastradh { 0x080c, 0x610914 }, 102*d350ecf5Sriastradh { 0x0810, 0x610904 }, 103*d350ecf5Sriastradh {} 104*d350ecf5Sriastradh } 105*d350ecf5Sriastradh }; 106*d350ecf5Sriastradh 107*d350ecf5Sriastradh static const struct nv50_disp_chan_mthd 108*d350ecf5Sriastradh nv50_disp_base_chan_mthd = { 109*d350ecf5Sriastradh .name = "Base", 110*d350ecf5Sriastradh .addr = 0x000540, 111*d350ecf5Sriastradh .prev = 0x000004, 112*d350ecf5Sriastradh .data = { 113*d350ecf5Sriastradh { "Global", 1, &nv50_disp_base_mthd_base }, 114*d350ecf5Sriastradh { "Image", 2, &nv50_disp_base_mthd_image }, 115*d350ecf5Sriastradh {} 116*d350ecf5Sriastradh } 117*d350ecf5Sriastradh }; 118*d350ecf5Sriastradh 119*d350ecf5Sriastradh const struct nv50_disp_dmac_oclass 120*d350ecf5Sriastradh nv50_disp_base_oclass = { 121*d350ecf5Sriastradh .base.oclass = NV50_DISP_BASE_CHANNEL_DMA, 122*d350ecf5Sriastradh .base.minver = 0, 123*d350ecf5Sriastradh .base.maxver = 0, 124*d350ecf5Sriastradh .ctor = nv50_disp_base_new, 125*d350ecf5Sriastradh .func = &nv50_disp_dmac_func, 126*d350ecf5Sriastradh .mthd = &nv50_disp_base_chan_mthd, 127*d350ecf5Sriastradh .chid = 1, 128*d350ecf5Sriastradh }; 129