Home | History | Annotate | Line # | Download | only in disp
      1 /*	$NetBSD: nouveau_nvkm_engine_disp_hdmigf119.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_hdmigf119.c,v 1.3 2021/12/18 23:45:35 riastradh Exp $");
     28 
     29 #include "hdmi.h"
     30 
     31 void
     32 gf119_hdmi_ctrl(struct nvkm_ior *ior, int head, bool enable, u8 max_ac_packet,
     33 		u8 rekey, u8 *avi, u8 avi_size, u8 *vendor, u8 vendor_size)
     34 {
     35 	struct nvkm_device *device = ior->disp->engine.subdev.device;
     36 	const u32 ctrl = 0x40000000 * enable |
     37 			 max_ac_packet << 16 |
     38 			 rekey;
     39 	const u32 hoff = head * 0x800;
     40 	struct packed_hdmi_infoframe avi_infoframe;
     41 	struct packed_hdmi_infoframe vendor_infoframe;
     42 
     43 	pack_hdmi_infoframe(&avi_infoframe, avi, avi_size);
     44 	pack_hdmi_infoframe(&vendor_infoframe, vendor, vendor_size);
     45 
     46 	if (!(ctrl & 0x40000000)) {
     47 		nvkm_mask(device, 0x616798 + hoff, 0x40000000, 0x00000000);
     48 		nvkm_mask(device, 0x616730 + hoff, 0x00000001, 0x00000000);
     49 		nvkm_mask(device, 0x6167a4 + hoff, 0x00000001, 0x00000000);
     50 		nvkm_mask(device, 0x616714 + hoff, 0x00000001, 0x00000000);
     51 		return;
     52 	}
     53 
     54 	/* AVI InfoFrame */
     55 	nvkm_mask(device, 0x616714 + hoff, 0x00000001, 0x00000000);
     56 	if (avi_size) {
     57 		nvkm_wr32(device, 0x61671c + hoff, avi_infoframe.header);
     58 		nvkm_wr32(device, 0x616720 + hoff, avi_infoframe.subpack0_low);
     59 		nvkm_wr32(device, 0x616724 + hoff, avi_infoframe.subpack0_high);
     60 		nvkm_wr32(device, 0x616728 + hoff, avi_infoframe.subpack1_low);
     61 		nvkm_wr32(device, 0x61672c + hoff, avi_infoframe.subpack1_high);
     62 		nvkm_mask(device, 0x616714 + hoff, 0x00000001, 0x00000001);
     63 	}
     64 
     65 	/* GENERIC(?) / Vendor InfoFrame? */
     66 	nvkm_mask(device, 0x616730 + hoff, 0x00010001, 0x00010000);
     67 	if (vendor_size) {
     68 		/*
     69 		 * These appear to be the audio infoframe registers,
     70 		 * but no other set of infoframe registers has yet
     71 		 * been found.
     72 		 */
     73 		nvkm_wr32(device, 0x616738 + hoff, vendor_infoframe.header);
     74 		nvkm_wr32(device, 0x61673c + hoff, vendor_infoframe.subpack0_low);
     75 		nvkm_wr32(device, 0x616740 + hoff, vendor_infoframe.subpack0_high);
     76 		/* Is there a second (or further?) set of subpack registers here? */
     77 		nvkm_mask(device, 0x616730 + hoff, 0x00000001, 0x00000001);
     78 	}
     79 
     80 	/* ??? InfoFrame? */
     81 	nvkm_mask(device, 0x6167a4 + hoff, 0x00000001, 0x00000000);
     82 	nvkm_wr32(device, 0x6167ac + hoff, 0x00000010);
     83 	nvkm_mask(device, 0x6167a4 + hoff, 0x00000001, 0x00000001);
     84 
     85 	/* HDMI_CTRL */
     86 	nvkm_mask(device, 0x616798 + hoff, 0x401f007f, ctrl);
     87 }
     88