nouveau_nvkm_engine_disp_hdmigk104.c revision 1.2
1/* $NetBSD: nouveau_nvkm_engine_disp_hdmigk104.c,v 1.2 2018/08/27 04:58:31 riastradh Exp $ */ 2 3/* 4 * Copyright 2014 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_hdmigk104.c,v 1.2 2018/08/27 04:58:31 riastradh Exp $"); 28 29#include "nv50.h" 30 31#include <core/client.h> 32 33#include <nvif/class.h> 34#include <nvif/unpack.h> 35 36int 37gk104_hdmi_ctrl(NV50_DISP_MTHD_V1) 38{ 39 struct nvkm_device *device = disp->base.engine.subdev.device; 40 const u32 hoff = (head * 0x800); 41 const u32 hdmi = (head * 0x400); 42 union { 43 struct nv50_disp_sor_hdmi_pwr_v0 v0; 44 } *args = data; 45 u32 ctrl; 46 int ret; 47 48 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size); 49 if (nvif_unpack(args->v0, 0, 0, false)) { 50 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d " 51 "max_ac_packet %d rekey %d\n", 52 args->v0.version, args->v0.state, 53 args->v0.max_ac_packet, args->v0.rekey); 54 if (args->v0.max_ac_packet > 0x1f || args->v0.rekey > 0x7f) 55 return -EINVAL; 56 ctrl = 0x40000000 * !!args->v0.state; 57 ctrl |= args->v0.max_ac_packet << 16; 58 ctrl |= args->v0.rekey; 59 } else 60 return ret; 61 62 if (!(ctrl & 0x40000000)) { 63 nvkm_mask(device, 0x616798 + hoff, 0x40000000, 0x00000000); 64 nvkm_mask(device, 0x6900c0 + hdmi, 0x00000001, 0x00000000); 65 nvkm_mask(device, 0x690000 + hdmi, 0x00000001, 0x00000000); 66 return 0; 67 } 68 69 /* AVI InfoFrame */ 70 nvkm_mask(device, 0x690000 + hdmi, 0x00000001, 0x00000000); 71 nvkm_wr32(device, 0x690008 + hdmi, 0x000d0282); 72 nvkm_wr32(device, 0x69000c + hdmi, 0x0000006f); 73 nvkm_wr32(device, 0x690010 + hdmi, 0x00000000); 74 nvkm_wr32(device, 0x690014 + hdmi, 0x00000000); 75 nvkm_wr32(device, 0x690018 + hdmi, 0x00000000); 76 nvkm_mask(device, 0x690000 + hdmi, 0x00000001, 0x00000001); 77 78 /* ??? InfoFrame? */ 79 nvkm_mask(device, 0x6900c0 + hdmi, 0x00000001, 0x00000000); 80 nvkm_wr32(device, 0x6900cc + hdmi, 0x00000010); 81 nvkm_mask(device, 0x6900c0 + hdmi, 0x00000001, 0x00000001); 82 83 /* ??? */ 84 nvkm_wr32(device, 0x690080 + hdmi, 0x82000000); 85 86 /* HDMI_CTRL */ 87 nvkm_mask(device, 0x616798 + hoff, 0x401f007f, ctrl); 88 return 0; 89} 90