2 * Copyright 2021 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 <nvif/conn.h>
23 #include <nvif/disp.h>
24 #include <nvif/printf.h>
26 #include <nvif/class.h>
27 #include <nvif/if0011.h>
30 nvif_conn_event_ctor(struct nvif_conn *conn, const char *name, nvif_event_func func, u8 types,
31 struct nvif_event *event)
34 struct nvif_event_v0 base;
35 struct nvif_conn_event_v0 conn;
39 args.conn.version = 0;
40 args.conn.types = types;
42 ret = nvif_event_ctor_(&conn->object, name ?: "nvifConnHpd", nvif_conn_id(conn),
43 func, true, &args.base, sizeof(args), false, event);
44 NVIF_DEBUG(&conn->object, "[NEW EVENT:HPD types:%02x]", types);
49 nvif_conn_dtor(struct nvif_conn *conn)
51 nvif_object_dtor(&conn->object);
55 nvif_conn_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_conn *conn)
57 struct nvif_conn_v0 args;
63 ret = nvif_object_ctor(&disp->object, name ?: "nvifConn", id, NVIF_CLASS_CONN,
64 &args, sizeof(args), &conn->object);
65 NVIF_ERRON(ret, &disp->object, "[NEW conn id:%d]", id);
72 case NVIF_CONN_V0_VGA : conn->info.type = NVIF_CONN_VGA; break;
73 case NVIF_CONN_V0_TV : conn->info.type = NVIF_CONN_TV; break;
74 case NVIF_CONN_V0_DVI_I : conn->info.type = NVIF_CONN_DVI_I; break;
75 case NVIF_CONN_V0_DVI_D : conn->info.type = NVIF_CONN_DVI_D; break;
76 case NVIF_CONN_V0_LVDS : conn->info.type = NVIF_CONN_LVDS; break;
77 case NVIF_CONN_V0_LVDS_SPWG: conn->info.type = NVIF_CONN_LVDS_SPWG; break;
78 case NVIF_CONN_V0_HDMI : conn->info.type = NVIF_CONN_HDMI; break;
79 case NVIF_CONN_V0_DP : conn->info.type = NVIF_CONN_DP; break;
80 case NVIF_CONN_V0_EDP : conn->info.type = NVIF_CONN_EDP; break;