Linux-libre 4.14.68-gnu
[librecmc/linux-libre.git] / drivers / gpu / drm / nouveau / nvkm / engine / disp / outp.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NVKM_DISP_OUTP_H__
3 #define __NVKM_DISP_OUTP_H__
4 #include <engine/disp.h>
5
6 #include <subdev/bios.h>
7 #include <subdev/bios/dcb.h>
8
9 struct nvkm_outp {
10         const struct nvkm_outp_func *func;
11         struct nvkm_disp *disp;
12         int index;
13         struct dcb_output info;
14
15         struct nvkm_i2c_bus *i2c;
16         int or;
17
18         struct list_head head;
19         struct nvkm_conn *conn;
20
21         /* Assembly state. */
22 #define NVKM_OUTP_PRIV 1
23 #define NVKM_OUTP_USER 2
24         u8 acquired:2;
25         struct nvkm_ior *ior;
26 };
27
28 int nvkm_outp_ctor(const struct nvkm_outp_func *, struct nvkm_disp *,
29                    int index, struct dcb_output *, struct nvkm_outp *);
30 int nvkm_outp_new(struct nvkm_disp *, int index, struct dcb_output *,
31                   struct nvkm_outp **);
32 void nvkm_outp_del(struct nvkm_outp **);
33 void nvkm_outp_init(struct nvkm_outp *);
34 void nvkm_outp_fini(struct nvkm_outp *);
35 int nvkm_outp_acquire(struct nvkm_outp *, u8 user);
36 void nvkm_outp_release(struct nvkm_outp *, u8 user);
37 void nvkm_outp_route(struct nvkm_disp *);
38
39 struct nvkm_outp_func {
40         void *(*dtor)(struct nvkm_outp *);
41         void (*init)(struct nvkm_outp *);
42         void (*fini)(struct nvkm_outp *);
43         int (*acquire)(struct nvkm_outp *);
44         void (*release)(struct nvkm_outp *, struct nvkm_ior *);
45 };
46
47 #define OUTP_MSG(o,l,f,a...) do {                                              \
48         struct nvkm_outp *_outp = (o);                                         \
49         nvkm_##l(&_outp->disp->engine.subdev, "outp %02x:%04x:%04x: "f"\n",    \
50                  _outp->index, _outp->info.hasht, _outp->info.hashm, ##a);     \
51 } while(0)
52 #define OUTP_ERR(o,f,a...) OUTP_MSG((o), error, f, ##a)
53 #define OUTP_DBG(o,f,a...) OUTP_MSG((o), debug, f, ##a)
54 #define OUTP_TRACE(o,f,a...) OUTP_MSG((o), trace, f, ##a)
55 #endif