Home | History | Annotate | Line # | Download | only in disp
      1 /*	$NetBSD: nouveau_nvkm_engine_disp_wimmgv100.c,v 1.3 2021/12/19 10:51:57 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright 2018 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 #include <sys/cdefs.h>
     25 __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_engine_disp_wimmgv100.c,v 1.3 2021/12/19 10:51:57 riastradh Exp $");
     26 
     27 #include "channv50.h"
     28 
     29 #include <core/client.h>
     30 
     31 #include <nvif/clc37b.h>
     32 #include <nvif/unpack.h>
     33 
     34 static void
     35 gv100_disp_wimm_intr(struct nv50_disp_chan *chan, bool en)
     36 {
     37 	struct nvkm_device *device = chan->disp->base.engine.subdev.device;
     38 	const u32 mask = 0x00000001 << chan->head;
     39 	const u32 data = en ? mask : 0;
     40 	nvkm_mask(device, 0x611da8, mask, data);
     41 }
     42 
     43 const struct nv50_disp_chan_func
     44 gv100_disp_wimm = {
     45 	.init = gv100_disp_dmac_init,
     46 	.fini = gv100_disp_dmac_fini,
     47 	.intr = gv100_disp_wimm_intr,
     48 	.user = gv100_disp_chan_user,
     49 };
     50 
     51 static int
     52 gv100_disp_wimm_new_(const struct nv50_disp_chan_func *func,
     53 		     const struct nv50_disp_chan_mthd *mthd,
     54 		     struct nv50_disp *disp, int chid,
     55 		     const struct nvkm_oclass *oclass, void *argv, u32 argc,
     56 		     struct nvkm_object **pobject)
     57 {
     58 	union {
     59 		struct nvc37b_window_imm_channel_dma_v0 v0;
     60 	} *args = argv;
     61 	struct nvkm_object *parent = oclass->parent;
     62 	int wndw, ret = -ENOSYS;
     63 	u64 push;
     64 
     65 	nvif_ioctl(parent, "create window imm channel dma size %d\n", argc);
     66 	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
     67 		nvif_ioctl(parent, "create window imm channel dma vers %d "
     68 				   "pushbuf %016"PRIx64" index %d\n",
     69 			   args->v0.version, args->v0.pushbuf, args->v0.index);
     70 		if (!(disp->wndw.mask & BIT(args->v0.index)))
     71 			return -EINVAL;
     72 		push = args->v0.pushbuf;
     73 		wndw = args->v0.index;
     74 	} else
     75 		return ret;
     76 
     77 	return nv50_disp_dmac_new_(func, mthd, disp, chid + wndw,
     78 				   wndw, push, oclass, pobject);
     79 }
     80 
     81 int
     82 gv100_disp_wimm_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
     83 		    struct nv50_disp *disp, struct nvkm_object **pobject)
     84 {
     85 	return gv100_disp_wimm_new_(&gv100_disp_wimm, NULL, disp, 33,
     86 				    oclass, argv, argc, pobject);
     87 }
     88