1/* $NetBSD: nouveau_nvkm_engine_disp_ovlynv50.c,v 1.3 2021/12/18 23:45:35 riastradh Exp $ */ 2 3/* 4 * Copyright 2012 Red Hat Inc. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * OTHER DEALINGS IN THE SOFTWARE. 23 * 24 * Authors: Ben Skeggs 25 */ 26#include <sys/cdefs.h> 27__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_disp_ovlynv50.c,v 1.3 2021/12/18 23:45:35 riastradh Exp $"); 28 29#include "channv50.h" 30#include "head.h" 31 32#include <core/client.h> 33 34#include <nvif/cl507e.h> 35#include <nvif/unpack.h> 36 37int 38nv50_disp_ovly_new_(const struct nv50_disp_chan_func *func, 39 const struct nv50_disp_chan_mthd *mthd, 40 struct nv50_disp *disp, int chid, 41 const struct nvkm_oclass *oclass, void *argv, u32 argc, 42 struct nvkm_object **pobject) 43{ 44 union { 45 struct nv50_disp_overlay_channel_dma_v0 v0; 46 } *args = argv; 47 struct nvkm_object *parent = oclass->parent; 48 int head, ret = -ENOSYS; 49 u64 push; 50 51 nvif_ioctl(parent, "create disp overlay channel dma size %d\n", argc); 52 if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) { 53 nvif_ioctl(parent, "create disp overlay channel dma vers %d " 54 "pushbuf %016"PRIx64" head %d\n", 55 args->v0.version, args->v0.pushbuf, args->v0.head); 56 if (!nvkm_head_find(&disp->base, args->v0.head)) 57 return -EINVAL; 58 push = args->v0.pushbuf; 59 head = args->v0.head; 60 } else 61 return ret; 62 63 return nv50_disp_dmac_new_(func, mthd, disp, chid + head, 64 head, push, oclass, pobject); 65} 66 67static const struct nv50_disp_mthd_list 68nv50_disp_ovly_mthd_base = { 69 .mthd = 0x0000, 70 .addr = 0x000000, 71 .data = { 72 { 0x0080, 0x000000 }, 73 { 0x0084, 0x0009a0 }, 74 { 0x0088, 0x0009c0 }, 75 { 0x008c, 0x0009c8 }, 76 { 0x0090, 0x6109b4 }, 77 { 0x0094, 0x610970 }, 78 { 0x00a0, 0x610998 }, 79 { 0x00a4, 0x610964 }, 80 { 0x00c0, 0x610958 }, 81 { 0x00e0, 0x6109a8 }, 82 { 0x00e4, 0x6109d0 }, 83 { 0x00e8, 0x6109d8 }, 84 { 0x0100, 0x61094c }, 85 { 0x0104, 0x610984 }, 86 { 0x0108, 0x61098c }, 87 { 0x0800, 0x6109f8 }, 88 { 0x0808, 0x610a08 }, 89 { 0x080c, 0x610a10 }, 90 { 0x0810, 0x610a00 }, 91 {} 92 } 93}; 94 95static const struct nv50_disp_chan_mthd 96nv50_disp_ovly_mthd = { 97 .name = "Overlay", 98 .addr = 0x000540, 99 .prev = 0x000004, 100 .data = { 101 { "Global", 1, &nv50_disp_ovly_mthd_base }, 102 {} 103 } 104}; 105 106int 107nv50_disp_ovly_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, 108 struct nv50_disp *disp, struct nvkm_object **pobject) 109{ 110 return nv50_disp_ovly_new_(&nv50_disp_dmac_func, &nv50_disp_ovly_mthd, 111 disp, 3, oclass, argv, argc, pobject); 112} 113