1 /* SPDX-License-Identifier: MIT */
5 #include <linux/mutex.h>
6 #include <drm/drm_crtc.h>
7 #include <drm/drm_vblank_work.h>
10 #include <nvkm/subdev/bios.h>
11 #include "nouveau_encoder.h"
17 #if IS_ENABLED(CONFIG_DEBUG_FS)
18 enum nv50_crc_source {
19 NV50_CRC_SOURCE_NONE = 0,
22 NV50_CRC_SOURCE_OUTP_ACTIVE,
23 NV50_CRC_SOURCE_OUTP_COMPLETE,
24 NV50_CRC_SOURCE_OUTP_INACTIVE,
32 enum nv50_crc_source_type {
33 NV50_CRC_SOURCE_TYPE_NONE = 0,
34 NV50_CRC_SOURCE_TYPE_SOR,
35 NV50_CRC_SOURCE_TYPE_PIOR,
36 NV50_CRC_SOURCE_TYPE_DAC,
37 NV50_CRC_SOURCE_TYPE_RG,
38 NV50_CRC_SOURCE_TYPE_SF,
41 struct nv50_crc_notifier_ctx {
43 struct nvif_object ntfy;
46 struct nv50_crc_atom {
47 enum nv50_crc_source src;
50 struct nv50_crc_func {
51 int (*set_src)(struct nv50_head *, int or, enum nv50_crc_source_type type,
52 struct nv50_crc_notifier_ctx *ctx);
53 int (*set_ctx)(struct nv50_head *, struct nv50_crc_notifier_ctx *);
54 u32 (*get_entry)(struct nv50_head *, struct nv50_crc_notifier_ctx *,
55 enum nv50_crc_source, int idx);
56 bool (*ctx_finished)(struct nv50_head *,
57 struct nv50_crc_notifier_ctx *);
65 struct nv50_crc_notifier_ctx ctx[2];
66 struct drm_vblank_work flip_work;
67 enum nv50_crc_source src;
76 void nv50_crc_init(struct drm_device *dev);
77 int nv50_head_crc_late_register(struct nv50_head *);
78 void nv50_crc_handle_vblank(struct nv50_head *head);
80 int nv50_crc_verify_source(struct drm_crtc *, const char *, size_t *);
81 const char *const *nv50_crc_get_sources(struct drm_crtc *, size_t *);
82 int nv50_crc_set_source(struct drm_crtc *, const char *);
84 int nv50_crc_atomic_check_head(struct nv50_head *, struct nv50_head_atom *,
85 struct nv50_head_atom *);
86 void nv50_crc_atomic_check_outp(struct nv50_atom *atom);
87 void nv50_crc_atomic_stop_reporting(struct drm_atomic_state *);
88 void nv50_crc_atomic_init_notifier_contexts(struct drm_atomic_state *);
89 void nv50_crc_atomic_release_notifier_contexts(struct drm_atomic_state *);
90 void nv50_crc_atomic_start_reporting(struct drm_atomic_state *);
91 void nv50_crc_atomic_set(struct nv50_head *, struct nv50_head_atom *);
92 void nv50_crc_atomic_clr(struct nv50_head *);
94 extern const struct nv50_crc_func crc907d;
95 extern const struct nv50_crc_func crcc37d;
96 extern const struct nv50_crc_func crcc57d;
98 #else /* IS_ENABLED(CONFIG_DEBUG_FS) */
100 struct nv50_crc_func {};
101 struct nv50_crc_atom {};
103 #define nv50_crc_verify_source NULL
104 #define nv50_crc_get_sources NULL
105 #define nv50_crc_set_source NULL
107 static inline void nv50_crc_init(struct drm_device *dev) {}
109 nv50_head_crc_late_register(struct nv50_head *head) { return 0; }
110 static inline void nv50_crc_handle_vblank(struct nv50_head *head) {}
113 nv50_crc_atomic_check_head(struct nv50_head *head,
114 struct nv50_head_atom *asyh,
115 struct nv50_head_atom *armh) { return 0; }
116 static inline void nv50_crc_atomic_check_outp(struct nv50_atom *atom) {}
118 nv50_crc_atomic_stop_reporting(struct drm_atomic_state *state) {}
120 nv50_crc_atomic_init_notifier_contexts(struct drm_atomic_state *state) {}
122 nv50_crc_atomic_release_notifier_contexts(struct drm_atomic_state *state) {}
124 nv50_crc_atomic_start_reporting(struct drm_atomic_state *state) {}
126 nv50_crc_atomic_set(struct nv50_head *head, struct nv50_head_atom *state) {}
128 nv50_crc_atomic_clr(struct nv50_head *head) {}
130 #endif /* IS_ENABLED(CONFIG_DEBUG_FS) */
131 #endif /* !__NV50_CRC_H__ */