2 * Copyright 2014 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.
26 #include <subdev/bios.h>
27 #include <subdev/bios/dcb.h>
28 #include <subdev/i2c.h>
31 nvkm_output_fini(struct nvkm_output *outp)
34 outp->func->fini(outp);
38 nvkm_output_init(struct nvkm_output *outp)
41 outp->func->init(outp);
45 nvkm_output_del(struct nvkm_output **poutp)
47 struct nvkm_output *outp = *poutp;
48 if (outp && !WARN_ON(!outp->func)) {
50 *poutp = outp->func->dtor(outp);
57 nvkm_output_ctor(const struct nvkm_output_func *func, struct nvkm_disp *disp,
58 int index, struct dcb_output *dcbE, struct nvkm_output *outp)
60 struct nvkm_i2c *i2c = disp->engine.subdev.device->i2c;
66 outp->i2c = nvkm_i2c_bus_find(i2c, dcbE->i2c_index);
67 outp->or = ffs(outp->info.or) - 1;
69 OUTP_DBG(outp, "type %02x loc %d or %d link %d con %x "
70 "edid %x bus %d head %x",
71 outp->info.type, outp->info.location, outp->info.or,
72 outp->info.type >= 2 ? outp->info.sorconf.link : 0,
73 outp->info.connector, outp->info.i2c_index,
74 outp->info.bus, outp->info.heads);
78 nvkm_output_new_(const struct nvkm_output_func *func,
79 struct nvkm_disp *disp, int index, struct dcb_output *dcbE,
80 struct nvkm_output **poutp)
82 if (!(*poutp = kzalloc(sizeof(**poutp), GFP_KERNEL)))
85 nvkm_output_ctor(func, disp, index, dcbE, *poutp);