Lines Matching full:crc

21 #include "crc.h"
79 core->func->crc->set_ctx(head, ctx); in nv50_crc_program_ctx()
86 struct nv50_crc *crc = container_of(work, struct nv50_crc, flip_work); in nv50_crc_ctx_flip_work() local
87 struct nv50_head *head = container_of(crc, struct nv50_head, crc); in nv50_crc_ctx_flip_work()
93 u8 new_idx = crc->ctx_idx ^ 1; in nv50_crc_ctx_flip_work()
100 drm_dbg_kms(dev, "Lock contended, delaying CRC ctx flip for %s\n", crtc->name); in nv50_crc_ctx_flip_work()
106 crtc->name, crc->ctx_idx, new_idx); in nv50_crc_ctx_flip_work()
109 nv50_crc_program_ctx(head, &crc->ctx[new_idx]); in nv50_crc_ctx_flip_work()
115 "Failed to flip CRC context on %s on time (%llu > %llu)\n", in nv50_crc_ctx_flip_work()
118 spin_lock_irq(&crc->lock); in nv50_crc_ctx_flip_work()
119 crc->ctx_changed = true; in nv50_crc_ctx_flip_work()
120 spin_unlock_irq(&crc->lock); in nv50_crc_ctx_flip_work()
134 struct nv50_crc *crc = &head->crc; in nv50_crc_get_entries() local
137 while (crc->entry_idx < func->num_entries) { in nv50_crc_get_entries()
143 output_crc = func->get_entry(head, &crc->ctx[crc->ctx_idx], in nv50_crc_get_entries()
144 source, crc->entry_idx); in nv50_crc_get_entries()
148 drm_crtc_add_crc_entry(crtc, true, crc->frame, &output_crc); in nv50_crc_get_entries()
149 crc->frame++; in nv50_crc_get_entries()
150 crc->entry_idx++; in nv50_crc_get_entries()
157 struct nv50_crc *crc = &head->crc; in nv50_crc_handle_vblank() local
159 nv50_disp(head->base.base.dev)->core->func->crc; in nv50_crc_handle_vblank()
171 if (!spin_trylock(&crc->lock)) in nv50_crc_handle_vblank()
174 if (!crc->src) in nv50_crc_handle_vblank()
177 ctx = &crc->ctx[crc->ctx_idx]; in nv50_crc_handle_vblank()
178 if (crc->ctx_changed && func->ctx_finished(head, ctx)) { in nv50_crc_handle_vblank()
179 nv50_crc_get_entries(head, func, crc->src); in nv50_crc_handle_vblank()
181 crc->ctx_idx ^= 1; in nv50_crc_handle_vblank()
182 crc->entry_idx = 0; in nv50_crc_handle_vblank()
183 crc->ctx_changed = false; in nv50_crc_handle_vblank()
186 * Unfortunately when notifier contexts are changed during CRC in nv50_crc_handle_vblank()
187 * capture, we will inevitably lose the CRC entry for the in nv50_crc_handle_vblank()
199 "Notifier ctx flip for head-%d finished, lost CRC for frame %llu\n", in nv50_crc_handle_vblank()
200 head->base.index, crc->frame); in nv50_crc_handle_vblank()
201 crc->frame++; in nv50_crc_handle_vblank()
207 nv50_crc_get_entries(head, func, crc->src); in nv50_crc_handle_vblank()
210 drm_vblank_work_schedule(&crc->flip_work, in nv50_crc_handle_vblank()
212 + crc->flip_threshold in nv50_crc_handle_vblank()
213 - crc->entry_idx, in nv50_crc_handle_vblank()
217 spin_unlock(&crc->lock); in nv50_crc_handle_vblank()
232 "CRC notifier ctx for head %d not finished after 50ms\n", in nv50_crc_wait_ctx_finished()
236 "CRC notifier ctx for head-%d finished after %lldns\n", in nv50_crc_wait_ctx_finished()
249 struct nv50_crc *crc = &head->crc; in nv50_crc_atomic_stop_reporting() local
251 if (!asyh->clr.crc) in nv50_crc_atomic_stop_reporting()
254 spin_lock_irq(&crc->lock); in nv50_crc_atomic_stop_reporting()
255 crc->src = NV50_CRC_SOURCE_NONE; in nv50_crc_atomic_stop_reporting()
256 spin_unlock_irq(&crc->lock); in nv50_crc_atomic_stop_reporting()
259 drm_vblank_work_cancel_sync(&crc->flip_work); in nv50_crc_atomic_stop_reporting()
262 "CRC reporting on vblank for head-%d disabled\n", in nv50_crc_atomic_stop_reporting()
265 /* CRC generation is still enabled in hw, we'll just report in nv50_crc_atomic_stop_reporting()
266 * any remaining CRC entries ourselves after it gets disabled in nv50_crc_atomic_stop_reporting()
281 struct nv50_crc *crc = &head->crc; in nv50_crc_atomic_init_notifier_contexts() local
284 if (!asyh->set.crc) in nv50_crc_atomic_init_notifier_contexts()
287 crc->entry_idx = 0; in nv50_crc_atomic_init_notifier_contexts()
288 crc->ctx_changed = false; in nv50_crc_atomic_init_notifier_contexts()
289 for (i = 0; i < ARRAY_SIZE(crc->ctx); i++) in nv50_crc_atomic_init_notifier_contexts()
290 nv50_crc_reset_ctx(&crc->ctx[i]); in nv50_crc_atomic_init_notifier_contexts()
297 nv50_disp(state->dev)->core->func->crc; in nv50_crc_atomic_release_notifier_contexts()
305 struct nv50_crc *crc = &head->crc; in nv50_crc_atomic_release_notifier_contexts() local
306 struct nv50_crc_notifier_ctx *ctx = &crc->ctx[crc->ctx_idx]; in nv50_crc_atomic_release_notifier_contexts()
308 if (!asyh->clr.crc) in nv50_crc_atomic_release_notifier_contexts()
311 if (crc->ctx_changed) { in nv50_crc_atomic_release_notifier_contexts()
313 ctx = &crc->ctx[crc->ctx_idx ^ 1]; in nv50_crc_atomic_release_notifier_contexts()
328 struct nv50_crc *crc = &head->crc; in nv50_crc_atomic_start_reporting() local
331 if (!asyh->set.crc) in nv50_crc_atomic_start_reporting()
336 spin_lock_irq(&crc->lock); in nv50_crc_atomic_start_reporting()
338 crc->frame = vbl_count; in nv50_crc_atomic_start_reporting()
339 crc->src = asyh->crc.src; in nv50_crc_atomic_start_reporting()
340 drm_vblank_work_schedule(&crc->flip_work, in nv50_crc_atomic_start_reporting()
341 vbl_count + crc->flip_threshold, in nv50_crc_atomic_start_reporting()
343 spin_unlock_irq(&crc->lock); in nv50_crc_atomic_start_reporting()
346 "CRC reporting on vblank for head-%d enabled\n", in nv50_crc_atomic_start_reporting()
356 bool changed = armh->crc.src != asyh->crc.src; in nv50_crc_atomic_check_head()
358 if (!armh->crc.src && !asyh->crc.src) { in nv50_crc_atomic_check_head()
359 asyh->set.crc = false; in nv50_crc_atomic_check_head()
360 asyh->clr.crc = false; in nv50_crc_atomic_check_head()
365 asyh->clr.crc = armh->crc.src && armh->state.active; in nv50_crc_atomic_check_head()
366 asyh->set.crc = asyh->crc.src && asyh->state.active; in nv50_crc_atomic_check_head()
371 if (asyh->clr.crc && asyh->set.crc) in nv50_crc_atomic_check_head()
374 asyh->set.crc = false; in nv50_crc_atomic_check_head()
375 asyh->clr.crc = false; in nv50_crc_atomic_check_head()
408 if (!asyh->clr.crc) in nv50_crc_atomic_check_outp()
455 struct nv50_crc *crc = &head->crc; in nv50_crc_atomic_set() local
456 const struct nv50_crc_func *func = nv50_disp(dev)->core->func->crc; in nv50_crc_atomic_set()
468 func->set_src(head, outp->outp.or.id, nv50_crc_source_type(outp, asyh->crc.src), in nv50_crc_atomic_set()
469 &crc->ctx[crc->ctx_idx]); in nv50_crc_atomic_set()
475 nv50_disp(head->base.base.dev)->core->func->crc; in nv50_crc_atomic_clr()
498 /* We handle mapping the memory for CRC notifiers ourselves, since each
546 struct nv50_crc *crc = &head->crc; in nv50_crc_set_source() local
547 const struct nv50_crc_func *func = nv50_disp(dev)->core->func->crc; in nv50_crc_set_source()
574 for (i = 0; i < ARRAY_SIZE(head->crc.ctx); i++) { in nv50_crc_set_source()
575 ret = nv50_crc_ctx_init(head, mmu, &crc->ctx[i], in nv50_crc_set_source()
592 asyh->crc.src = source; in nv50_crc_set_source()
606 crc->flip_threshold = func->flip_threshold; in nv50_crc_set_source()
613 for (i = 0; i < ARRAY_SIZE(crc->ctx); i++) in nv50_crc_set_source()
614 nv50_crc_ctx_fini(&crc->ctx[i]); in nv50_crc_set_source()
632 struct nv50_crc *crc = &head->crc; in nv50_crc_debugfs_flip_threshold_get() local
639 seq_printf(m, "%d\n", crc->flip_threshold); in nv50_crc_debugfs_flip_threshold_get()
662 struct nv50_crc *crc = &head->crc; in nv50_crc_debugfs_flip_threshold_set() local
664 nv50_disp(crtc->dev)->core->func->crc; in nv50_crc_debugfs_flip_threshold_set()
683 if (armh->crc.src) { in nv50_crc_debugfs_flip_threshold_set()
689 "Changing CRC flip threshold for next capture on head-%d to %d\n", in nv50_crc_debugfs_flip_threshold_set()
691 crc->flip_threshold = value; in nv50_crc_debugfs_flip_threshold_set()
711 nv50_disp(crtc->dev)->core->func->crc; in nv50_head_crc_late_register()
728 struct nv50_crc *crc = &head->crc; in nv50_crc_init_head() local
730 crc->flip_threshold = func->flip_threshold; in nv50_crc_init_head()
731 spin_lock_init(&crc->lock); in nv50_crc_init_head()
732 drm_vblank_work_init(&crc->flip_work, &head->base.base, in nv50_crc_init_head()
740 const struct nv50_crc_func *func = disp->core->func->crc; in nv50_crc_init()