1/*	$NetBSD: nouveau_nvkm_engine_disp_oimmnv50.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_oimmnv50.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/cl507b.h>
35#include <nvif/unpack.h>
36
37int
38nv50_disp_oimm_new_(const struct nv50_disp_chan_func *func,
39		    struct nv50_disp *disp, int ctrl, int user,
40		    const struct nvkm_oclass *oclass, void *argv, u32 argc,
41		    struct nvkm_object **pobject)
42{
43	union {
44		struct nv50_disp_overlay_v0 v0;
45	} *args = argv;
46	struct nvkm_object *parent = oclass->parent;
47	int head, ret = -ENOSYS;
48
49	nvif_ioctl(parent, "create disp overlay size %d\n", argc);
50	if (!(ret = nvif_unpack(ret, &argv, &argc, args->v0, 0, 0, false))) {
51		nvif_ioctl(parent, "create disp overlay vers %d head %d\n",
52			   args->v0.version, args->v0.head);
53		if (!nvkm_head_find(&disp->base, args->v0.head))
54			return -EINVAL;
55		head = args->v0.head;
56	} else
57		return ret;
58
59	return nv50_disp_chan_new_(func, NULL, disp, ctrl + head, user + head,
60				   head, oclass, pobject);
61}
62
63int
64nv50_disp_oimm_new(const struct nvkm_oclass *oclass, void *argv, u32 argc,
65		   struct nv50_disp *disp, struct nvkm_object **pobject)
66{
67	return nv50_disp_oimm_new_(&nv50_disp_pioc_func, disp, 5, 5,
68				   oclass, argv, argc, pobject);
69}
70