Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / drivers / gpu / drm / nouveau / nvkm / engine / disp / dacgf119.c
blobdbd032ef352ae6865b4f9edeaf098da534e03578
1 /*
2 * Copyright 2017 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
22 #include "ior.h"
24 static void
25 gf119_dac_clock(struct nvkm_ior *dac)
27 struct nvkm_device *device = dac->disp->engine.subdev.device;
28 const u32 doff = nv50_ior_base(dac);
29 nvkm_mask(device, 0x612280 + doff, 0x07070707, 0x00000000);
32 static void
33 gf119_dac_state(struct nvkm_ior *dac, struct nvkm_ior_state *state)
35 struct nvkm_device *device = dac->disp->engine.subdev.device;
36 const u32 coff = (state == &dac->asy) * 0x20000 + dac->id * 0x20;
37 u32 ctrl = nvkm_rd32(device, 0x640180 + coff);
39 state->proto_evo = (ctrl & 0x00000f00) >> 8;
40 switch (state->proto_evo) {
41 case 0: state->proto = CRT; break;
42 default:
43 state->proto = UNKNOWN;
44 break;
47 state->head = ctrl & 0x0000000f;
50 static const struct nvkm_ior_func
51 gf119_dac = {
52 .state = gf119_dac_state,
53 .power = nv50_dac_power,
54 .sense = nv50_dac_sense,
55 .clock = gf119_dac_clock,
58 int
59 gf119_dac_new(struct nvkm_disp *disp, int id)
61 struct nvkm_device *device = disp->engine.subdev.device;
62 if (!(nvkm_rd32(device, 0x612004) & (0x00000010 << id)))
63 return 0;
64 return nvkm_ior_new_(&gf119_dac, disp, DAC, id);