xref: /openbmc/linux/drivers/gpu/drm/nouveau/dispnv50/sor907d.c (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
109e1b78aSBen Skeggs /*
209e1b78aSBen Skeggs  * Copyright 2018 Red Hat Inc.
309e1b78aSBen Skeggs  *
409e1b78aSBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
509e1b78aSBen Skeggs  * copy of this software and associated documentation files (the "Software"),
609e1b78aSBen Skeggs  * to deal in the Software without restriction, including without limitation
709e1b78aSBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
809e1b78aSBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
909e1b78aSBen Skeggs  * Software is furnished to do so, subject to the following conditions:
1009e1b78aSBen Skeggs  *
1109e1b78aSBen Skeggs  * The above copyright notice and this permission notice shall be included in
1209e1b78aSBen Skeggs  * all copies or substantial portions of the Software.
1309e1b78aSBen Skeggs  *
1409e1b78aSBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1509e1b78aSBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1609e1b78aSBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1709e1b78aSBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1809e1b78aSBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1909e1b78aSBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2009e1b78aSBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
2109e1b78aSBen Skeggs  */
2209e1b78aSBen Skeggs #include "core.h"
2309e1b78aSBen Skeggs 
2409e1b78aSBen Skeggs #include <nvif/class.h>
259ec5e820SBen Skeggs #include <nvif/push507c.h>
2609e1b78aSBen Skeggs 
27344c2e5aSBen Skeggs #include <nvhw/class/cl907d.h>
28344c2e5aSBen Skeggs 
299ec5e820SBen Skeggs #include <nouveau_bo.h>
309ec5e820SBen Skeggs 
319ec5e820SBen Skeggs static int
sor907d_ctrl(struct nv50_core * core,int or,u32 ctrl,struct nv50_head_atom * asyh)3209e1b78aSBen Skeggs sor907d_ctrl(struct nv50_core *core, int or, u32 ctrl,
3309e1b78aSBen Skeggs 	     struct nv50_head_atom *asyh)
3409e1b78aSBen Skeggs {
359ec5e820SBen Skeggs 	struct nvif_push *push = core->chan.push;
369ec5e820SBen Skeggs 	int ret;
379ec5e820SBen Skeggs 
389ec5e820SBen Skeggs 	if ((ret = PUSH_WAIT(push, 2)))
399ec5e820SBen Skeggs 		return ret;
409ec5e820SBen Skeggs 
41344c2e5aSBen Skeggs 	PUSH_MTHD(push, NV907D, SOR_SET_CONTROL(or), ctrl);
429ec5e820SBen Skeggs 	return 0;
4309e1b78aSBen Skeggs }
4409e1b78aSBen Skeggs 
454a2cb418SLyude Paul static void
sor907d_get_caps(struct nv50_disp * disp,struct nouveau_encoder * outp,int or)464a2cb418SLyude Paul sor907d_get_caps(struct nv50_disp *disp, struct nouveau_encoder *outp, int or)
474a2cb418SLyude Paul {
48*ca31b0c0SBen Skeggs 	struct nouveau_bo *bo = disp->sync;
494a2cb418SLyude Paul 	const int off = or * 2;
50*ca31b0c0SBen Skeggs 	outp->caps.dp_interlace =
51*ca31b0c0SBen Skeggs 		NVBO_RV32(bo, off, NV907D_CORE_NOTIFIER_3, CAPABILITIES_CAP_SOR0_20, DP_INTERLACE);
524a2cb418SLyude Paul }
534a2cb418SLyude Paul 
5409e1b78aSBen Skeggs const struct nv50_outp_func
5509e1b78aSBen Skeggs sor907d = {
5609e1b78aSBen Skeggs 	.ctrl = sor907d_ctrl,
574a2cb418SLyude Paul 	.get_caps = sor907d_get_caps,
5809e1b78aSBen Skeggs };
59