Lines Matching +full:full +full:- +full:frame

45  * DRM device drivers can provide to userspace CRC information of each frame as
49 * file dri/0/crtc-N/crc/control in debugfs, with N being the :ref:`index of
51 * driver-specific) and the "auto" keyword, which will let the driver select a
52 * default source of frame CRCs for this CRTC.
54 * Once frame CRC generation is enabled, userspace can capture them by reading
55 * the dri/0/crtc-N/crc/data file. Each line in that file contains the frame
58 * of CRC fields is source-specific.
61 * the frame contents as supplied by userspace (eDP 1.3), in general the CRC
62 * computation is performed in an unspecified way and on frame contents that have
64 * rely on being able to generate matching CRC values for the frame contents that
73 * may result in a commit (even a full modeset).
75 * CRC results must be reliable across non-full-modeset atomic commits, so if a
77 * CRC generation, then the driver must mark that commit as a full modeset
79 * consistent results, generic userspace must re-setup CRC generation after a
85 struct drm_crtc *crtc = m->private; in crc_control_show()
87 if (crtc->funcs->get_crc_sources) { in crc_control_show()
89 const char *const *sources = crtc->funcs->get_crc_sources(crtc, in crc_control_show()
98 if (!crtc->funcs->verify_crc_source(crtc, sources[i], in crc_control_show()
100 if (strcmp(sources[i], crtc->crc.source)) in crc_control_show()
109 seq_printf(m, "%s*\n", crtc->crc.source); in crc_control_show()
115 struct drm_crtc *crtc = inode->i_private; in crc_control_open()
123 struct seq_file *m = file->private_data; in crc_control_write()
124 struct drm_crtc *crtc = m->private; in crc_control_write()
125 struct drm_crtc_crc *crc = &crtc->crc; in crc_control_write()
133 if (len > PAGE_SIZE - 1) { in crc_control_write()
136 return -E2BIG; in crc_control_write()
143 if (source[len - 1] == '\n') in crc_control_write()
144 source[len - 1] = '\0'; in crc_control_write()
146 ret = crtc->funcs->verify_crc_source(crtc, source, &values_cnt); in crc_control_write()
152 spin_lock_irq(&crc->lock); in crc_control_write()
154 if (crc->opened) { in crc_control_write()
155 spin_unlock_irq(&crc->lock); in crc_control_write()
157 return -EBUSY; in crc_control_write()
160 kfree(crc->source); in crc_control_write()
161 crc->source = source; in crc_control_write()
163 spin_unlock_irq(&crc->lock); in crc_control_write()
180 assert_spin_locked(&crc->lock); in crtc_crc_data_count()
181 return CIRC_CNT(crc->head, crc->tail, DRM_CRC_ENTRIES_NR); in crtc_crc_data_count()
186 kfree(crc->entries); in crtc_crc_cleanup()
187 crc->overflow = false; in crtc_crc_cleanup()
188 crc->entries = NULL; in crtc_crc_cleanup()
189 crc->head = 0; in crtc_crc_cleanup()
190 crc->tail = 0; in crtc_crc_cleanup()
191 crc->values_cnt = 0; in crtc_crc_cleanup()
192 crc->opened = false; in crtc_crc_cleanup()
197 struct drm_crtc *crtc = inode->i_private; in crtc_crc_open()
198 struct drm_crtc_crc *crc = &crtc->crc; in crtc_crc_open()
203 if (drm_drv_uses_atomic_modeset(crtc->dev)) { in crtc_crc_open()
204 ret = drm_modeset_lock_single_interruptible(&crtc->mutex); in crtc_crc_open()
208 if (!crtc->state->active) in crtc_crc_open()
209 ret = -EIO; in crtc_crc_open()
210 drm_modeset_unlock(&crtc->mutex); in crtc_crc_open()
216 ret = crtc->funcs->verify_crc_source(crtc, crc->source, &values_cnt); in crtc_crc_open()
221 return -EINVAL; in crtc_crc_open()
224 return -EINVAL; in crtc_crc_open()
228 return -ENOMEM; in crtc_crc_open()
230 spin_lock_irq(&crc->lock); in crtc_crc_open()
231 if (!crc->opened) { in crtc_crc_open()
232 crc->opened = true; in crtc_crc_open()
233 crc->entries = entries; in crtc_crc_open()
234 crc->values_cnt = values_cnt; in crtc_crc_open()
236 ret = -EBUSY; in crtc_crc_open()
238 spin_unlock_irq(&crc->lock); in crtc_crc_open()
245 ret = crtc->funcs->set_crc_source(crtc, crc->source); in crtc_crc_open()
252 spin_lock_irq(&crc->lock); in crtc_crc_open()
254 spin_unlock_irq(&crc->lock); in crtc_crc_open()
260 struct drm_crtc *crtc = filep->f_inode->i_private; in crtc_crc_release()
261 struct drm_crtc_crc *crc = &crtc->crc; in crtc_crc_release()
264 spin_lock_irq(&crc->lock); in crtc_crc_release()
265 crc->opened = false; in crtc_crc_release()
266 spin_unlock_irq(&crc->lock); in crtc_crc_release()
268 crtc->funcs->set_crc_source(crtc, NULL); in crtc_crc_release()
270 spin_lock_irq(&crc->lock); in crtc_crc_release()
272 spin_unlock_irq(&crc->lock); in crtc_crc_release()
278 * 1 frame field of 10 chars plus a number of CRC fields of 10 chars each, space
279 * separated, with a newline at the end and null-terminated.
287 struct drm_crtc *crtc = filep->f_inode->i_private; in crtc_crc_read()
288 struct drm_crtc_crc *crc = &crtc->crc; in crtc_crc_read()
293 spin_lock_irq(&crc->lock); in crtc_crc_read()
295 if (!crc->source) { in crtc_crc_read()
296 spin_unlock_irq(&crc->lock); in crtc_crc_read()
302 if (filep->f_flags & O_NONBLOCK) { in crtc_crc_read()
303 spin_unlock_irq(&crc->lock); in crtc_crc_read()
304 return -EAGAIN; in crtc_crc_read()
307 ret = wait_event_interruptible_lock_irq(crc->wq, in crtc_crc_read()
309 crc->lock); in crtc_crc_read()
311 spin_unlock_irq(&crc->lock); in crtc_crc_read()
317 entry = &crc->entries[crc->tail]; in crtc_crc_read()
319 if (count < LINE_LEN(crc->values_cnt)) { in crtc_crc_read()
320 spin_unlock_irq(&crc->lock); in crtc_crc_read()
321 return -EINVAL; in crtc_crc_read()
325 crc->tail = (crc->tail + 1) & (DRM_CRC_ENTRIES_NR - 1); in crtc_crc_read()
327 spin_unlock_irq(&crc->lock); in crtc_crc_read()
329 if (entry->has_frame_counter) in crtc_crc_read()
330 sprintf(buf, "0x%08x", entry->frame); in crtc_crc_read()
334 for (i = 0; i < crc->values_cnt; i++) in crtc_crc_read()
335 sprintf(buf + 10 + i * 11, " 0x%08x", entry->crcs[i]); in crtc_crc_read()
336 sprintf(buf + 10 + crc->values_cnt * 11, "\n"); in crtc_crc_read()
338 if (copy_to_user(user_buf, buf, LINE_LEN(crc->values_cnt))) in crtc_crc_read()
339 return -EFAULT; in crtc_crc_read()
341 return LINE_LEN(crc->values_cnt); in crtc_crc_read()
346 struct drm_crtc *crtc = file->f_inode->i_private; in crtc_crc_poll()
347 struct drm_crtc_crc *crc = &crtc->crc; in crtc_crc_poll()
350 poll_wait(file, &crc->wq, wait); in crtc_crc_poll()
352 spin_lock_irq(&crc->lock); in crtc_crc_poll()
353 if (crc->source && crtc_crc_data_count(crc)) in crtc_crc_poll()
355 spin_unlock_irq(&crc->lock); in crtc_crc_poll()
372 if (!crtc->funcs->set_crc_source || !crtc->funcs->verify_crc_source) in drm_debugfs_crtc_crc_add()
375 crc_ent = debugfs_create_dir("crc", crtc->debugfs_entry); in drm_debugfs_crtc_crc_add()
384 * drm_crtc_add_crc_entry - Add entry with CRC information for a frame
385 * @crtc: CRTC to which the frame belongs
386 * @has_frame: whether this entry has a frame number to go with
387 * @frame: number of the frame these CRCs are about
390 * For each frame, the driver polls the source of CRCs for new data and calls
394 uint32_t frame, uint32_t *crcs) in drm_crtc_add_crc_entry() argument
396 struct drm_crtc_crc *crc = &crtc->crc; in drm_crtc_add_crc_entry()
401 spin_lock_irqsave(&crc->lock, flags); in drm_crtc_add_crc_entry()
404 if (!crc->entries) { in drm_crtc_add_crc_entry()
405 spin_unlock_irqrestore(&crc->lock, flags); in drm_crtc_add_crc_entry()
406 return -EINVAL; in drm_crtc_add_crc_entry()
409 head = crc->head; in drm_crtc_add_crc_entry()
410 tail = crc->tail; in drm_crtc_add_crc_entry()
413 bool was_overflow = crc->overflow; in drm_crtc_add_crc_entry()
415 crc->overflow = true; in drm_crtc_add_crc_entry()
416 spin_unlock_irqrestore(&crc->lock, flags); in drm_crtc_add_crc_entry()
421 return -ENOBUFS; in drm_crtc_add_crc_entry()
424 entry = &crc->entries[head]; in drm_crtc_add_crc_entry()
425 entry->frame = frame; in drm_crtc_add_crc_entry()
426 entry->has_frame_counter = has_frame; in drm_crtc_add_crc_entry()
427 memcpy(&entry->crcs, crcs, sizeof(*crcs) * crc->values_cnt); in drm_crtc_add_crc_entry()
429 head = (head + 1) & (DRM_CRC_ENTRIES_NR - 1); in drm_crtc_add_crc_entry()
430 crc->head = head; in drm_crtc_add_crc_entry()
432 spin_unlock_irqrestore(&crc->lock, flags); in drm_crtc_add_crc_entry()
434 wake_up_interruptible(&crc->wq); in drm_crtc_add_crc_entry()