1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include "outp.h"
25
26#include <subdev/bios.h>
27#include <subdev/bios/dcb.h>
28#include <subdev/i2c.h>
29
30void
31nvkm_output_fini(struct nvkm_output *outp)
32{
33 if (outp->func->fini)
34 outp->func->fini(outp);
35}
36
37void
38nvkm_output_init(struct nvkm_output *outp)
39{
40 if (outp->func->init)
41 outp->func->init(outp);
42}
43
44void
45nvkm_output_del(struct nvkm_output **poutp)
46{
47 struct nvkm_output *outp = *poutp;
48 if (outp && !WARN_ON(!outp->func)) {
49 if (outp->func->dtor)
50 *poutp = outp->func->dtor(outp);
51 kfree(*poutp);
52 *poutp = NULL;
53 }
54}
55
56void
57nvkm_output_ctor(const struct nvkm_output_func *func, struct nvkm_disp *disp,
58 int index, struct dcb_output *dcbE, struct nvkm_output *outp)
59{
60 struct nvkm_i2c *i2c = disp->engine.subdev.device->i2c;
61
62 outp->func = func;
63 outp->disp = disp;
64 outp->index = index;
65 outp->info = *dcbE;
66 outp->i2c = nvkm_i2c_bus_find(i2c, dcbE->i2c_index);
67 outp->or = ffs(outp->info.or) - 1;
68
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);
75}
76
77int
78nvkm_output_new_(const struct nvkm_output_func *func,
79 struct nvkm_disp *disp, int index, struct dcb_output *dcbE,
80 struct nvkm_output **poutp)
81{
82 if (!(*poutp = kzalloc(sizeof(**poutp), GFP_KERNEL)))
83 return -ENOMEM;
84
85 nvkm_output_ctor(func, disp, index, dcbE, *poutp);
86 return 0;
87}
88