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 / headnv04.c
blobdcf459282aa12126c58b34b65c05c201fb382ec8
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 * Authors: Ben Skeggs <bskeggs@redhat.com>
24 #include "head.h"
26 static void
27 nv04_head_vblank_put(struct nvkm_head *head)
29 struct nvkm_device *device = head->disp->engine.subdev.device;
30 nvkm_wr32(device, 0x600140 + (head->id * 0x2000) , 0x00000000);
33 static void
34 nv04_head_vblank_get(struct nvkm_head *head)
36 struct nvkm_device *device = head->disp->engine.subdev.device;
37 nvkm_wr32(device, 0x600140 + (head->id * 0x2000) , 0x00000001);
40 static void
41 nv04_head_rgpos(struct nvkm_head *head, u16 *hline, u16 *vline)
43 struct nvkm_device *device = head->disp->engine.subdev.device;
44 u32 data = nvkm_rd32(device, 0x600868 + (head->id * 0x2000));
45 *hline = (data & 0xffff0000) >> 16;
46 *vline = (data & 0x0000ffff);
49 static void
50 nv04_head_state(struct nvkm_head *head, struct nvkm_head_state *state)
52 struct nvkm_device *device = head->disp->engine.subdev.device;
53 const u32 hoff = head->id * 0x0200;
54 state->vblanks = nvkm_rd32(device, 0x680800 + hoff) & 0x0000ffff;
55 state->vtotal = nvkm_rd32(device, 0x680804 + hoff) & 0x0000ffff;
56 state->vblanke = state->vtotal - 1;
57 state->hblanks = nvkm_rd32(device, 0x680820 + hoff) & 0x0000ffff;
58 state->htotal = nvkm_rd32(device, 0x680824 + hoff) & 0x0000ffff;
59 state->hblanke = state->htotal - 1;
62 static const struct nvkm_head_func
63 nv04_head = {
64 .state = nv04_head_state,
65 .rgpos = nv04_head_rgpos,
66 .vblank_get = nv04_head_vblank_get,
67 .vblank_put = nv04_head_vblank_put,
70 int
71 nv04_head_new(struct nvkm_disp *disp, int id)
73 return nvkm_head_new_(&nv04_head, disp, id);