2 * Copyright 2013 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.
30 nouveau_disp_hpd_check(struct nouveau_event *event, u32 types, int index)
32 struct nouveau_disp *disp = event->priv;
33 struct nvkm_output *outp;
34 list_for_each_entry(outp, &disp->outp, head) {
35 if (outp->conn->index == index) {
36 if (outp->conn->hpd.event)
45 _nouveau_disp_fini(struct nouveau_object *object, bool suspend)
47 struct nouveau_disp *disp = (void *)object;
48 struct nvkm_output *outp;
51 list_for_each_entry(outp, &disp->outp, head) {
52 ret = nv_ofuncs(outp)->fini(nv_object(outp), suspend);
57 return nouveau_engine_fini(&disp->base, suspend);
60 list_for_each_entry_continue_reverse(outp, &disp->outp, head) {
61 nv_ofuncs(outp)->init(nv_object(outp));
68 _nouveau_disp_init(struct nouveau_object *object)
70 struct nouveau_disp *disp = (void *)object;
71 struct nvkm_output *outp;
74 ret = nouveau_engine_init(&disp->base);
78 list_for_each_entry(outp, &disp->outp, head) {
79 ret = nv_ofuncs(outp)->init(nv_object(outp));
87 list_for_each_entry_continue_reverse(outp, &disp->outp, head) {
88 nv_ofuncs(outp)->fini(nv_object(outp), false);
95 _nouveau_disp_dtor(struct nouveau_object *object)
97 struct nouveau_disp *disp = (void *)object;
98 struct nvkm_output *outp, *outt;
100 nouveau_event_destroy(&disp->vblank);
102 list_for_each_entry_safe(outp, outt, &disp->outp, head) {
103 nouveau_object_ref(NULL, (struct nouveau_object **)&outp);
106 nouveau_engine_destroy(&disp->base);
110 nouveau_disp_create_(struct nouveau_object *parent,
111 struct nouveau_object *engine,
112 struct nouveau_oclass *oclass, int heads,
113 const char *intname, const char *extname,
114 int length, void **pobject)
116 struct nouveau_disp_impl *impl = (void *)oclass;
117 struct nouveau_bios *bios = nouveau_bios(parent);
118 struct nouveau_disp *disp;
119 struct nouveau_oclass **sclass;
120 struct nouveau_object *object;
121 struct dcb_output dcbE;
122 u8 hpd = 0, ver, hdr;
126 ret = nouveau_engine_create_(parent, engine, oclass, true,
127 intname, extname, length, pobject);
132 INIT_LIST_HEAD(&disp->outp);
134 /* create output objects for each display path in the vbios */
136 while ((data = dcb_outp_parse(bios, ++i, &ver, &hdr, &dcbE))) {
137 if (dcbE.type == DCB_OUTPUT_UNUSED)
139 if (dcbE.type == DCB_OUTPUT_EOL)
141 data = dcbE.location << 4 | dcbE.type;
143 oclass = nvkm_output_oclass;
145 while (sclass && sclass[0]) {
146 if (sclass[0]->handle == data) {
153 nouveau_object_ctor(*pobject, *pobject, oclass,
155 hpd = max(hpd, (u8)(dcbE.connector + 1));
158 ret = nouveau_event_create(3, hpd, &disp->hpd);
162 disp->hpd->priv = disp;
163 disp->hpd->check = nouveau_disp_hpd_check;
165 ret = nouveau_event_create(1, heads, &disp->vblank);