11b255f1cSBen Skeggs /* 21b255f1cSBen Skeggs * Copyright 2021 Red Hat Inc. 31b255f1cSBen Skeggs * 41b255f1cSBen Skeggs * Permission is hereby granted, free of charge, to any person obtaining a 51b255f1cSBen Skeggs * copy of this software and associated documentation files (the "Software"), 61b255f1cSBen Skeggs * to deal in the Software without restriction, including without limitation 71b255f1cSBen Skeggs * the rights to use, copy, modify, merge, publish, distribute, sublicense, 81b255f1cSBen Skeggs * and/or sell copies of the Software, and to permit persons to whom the 91b255f1cSBen Skeggs * Software is furnished to do so, subject to the following conditions: 101b255f1cSBen Skeggs * 111b255f1cSBen Skeggs * The above copyright notice and this permission notice shall be included in 121b255f1cSBen Skeggs * all copies or substantial portions of the Software. 131b255f1cSBen Skeggs * 141b255f1cSBen Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 151b255f1cSBen Skeggs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 161b255f1cSBen Skeggs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 171b255f1cSBen Skeggs * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 181b255f1cSBen Skeggs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 191b255f1cSBen Skeggs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 201b255f1cSBen Skeggs * OTHER DEALINGS IN THE SOFTWARE. 211b255f1cSBen Skeggs */ 221b255f1cSBen Skeggs #include <nvif/outp.h> 231b255f1cSBen Skeggs #include <nvif/disp.h> 241b255f1cSBen Skeggs #include <nvif/printf.h> 251b255f1cSBen Skeggs 261b255f1cSBen Skeggs #include <nvif/class.h> 271b255f1cSBen Skeggs #include <nvif/if0012.h> 281b255f1cSBen Skeggs 29*dfc4005fSBen Skeggs int 30*dfc4005fSBen Skeggs nvif_outp_load_detect(struct nvif_outp *outp, u32 loadval) 31*dfc4005fSBen Skeggs { 32*dfc4005fSBen Skeggs struct nvif_outp_load_detect_v0 args; 33*dfc4005fSBen Skeggs int ret; 34*dfc4005fSBen Skeggs 35*dfc4005fSBen Skeggs args.version = 0; 36*dfc4005fSBen Skeggs args.data = loadval; 37*dfc4005fSBen Skeggs 38*dfc4005fSBen Skeggs ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_LOAD_DETECT, &args, sizeof(args)); 39*dfc4005fSBen Skeggs NVIF_ERRON(ret, &outp->object, "[LOAD_DETECT data:%08x] load:%02x", args.data, args.load); 40*dfc4005fSBen Skeggs return ret < 0 ? ret : args.load; 41*dfc4005fSBen Skeggs } 42*dfc4005fSBen Skeggs 431b255f1cSBen Skeggs void 441b255f1cSBen Skeggs nvif_outp_dtor(struct nvif_outp *outp) 451b255f1cSBen Skeggs { 461b255f1cSBen Skeggs nvif_object_dtor(&outp->object); 471b255f1cSBen Skeggs } 481b255f1cSBen Skeggs 491b255f1cSBen Skeggs int 501b255f1cSBen Skeggs nvif_outp_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_outp *outp) 511b255f1cSBen Skeggs { 521b255f1cSBen Skeggs struct nvif_outp_v0 args; 531b255f1cSBen Skeggs int ret; 541b255f1cSBen Skeggs 551b255f1cSBen Skeggs args.version = 0; 561b255f1cSBen Skeggs args.id = id; 571b255f1cSBen Skeggs 581b255f1cSBen Skeggs ret = nvif_object_ctor(&disp->object, name ?: "nvifOutp", id, NVIF_CLASS_OUTP, 591b255f1cSBen Skeggs &args, sizeof(args), &outp->object); 601b255f1cSBen Skeggs NVIF_ERRON(ret, &disp->object, "[NEW outp id:%d]", id); 611b255f1cSBen Skeggs return ret; 621b255f1cSBen Skeggs } 63