Home | History | Annotate | Download | only in drm

Lines Matching defs:crc

48  * DOC: CRC ABI
50 * DRM device drivers can provide to userspace CRC information of each frame as
51 * it reached a given hardware component (a CRC sampling "source").
54 * file dri/0/crtc-N/crc/control in debugfs, with N being the index of the CRTC.
59 * Once frame CRC generation is enabled, userspace can capture them by reading
60 * the dri/0/crtc-N/crc/data file. Each line in that file contains the frame
62 * containing the CRC data. Fields are separated by a single space and the number
63 * of CRC fields is source-specific.
65 * Note that though in some cases the CRC is computed in a specified way and on
66 * the frame contents as supplied by userspace (eDP 1.3), in general the CRC
69 * rely on being able to generate matching CRC values for the frame contents that
75 * The debugfs files are automatically set up if those vfuncs are set. CRC samples
80 * CRC results must be reliable across non-full-modeset atomic commits, so if a
82 * CRC generation, then the driver must mark that commit as a full modeset
84 * consistent results, generic userspace must re-setup CRC generation after a
105 if (strcmp(sources[i], crtc->crc.source))
114 seq_printf(m, "%s*\n", crtc->crc.source);
130 struct drm_crtc_crc *crc = &crtc->crc;
139 DRM_DEBUG_KMS("Expected < %lu bytes into crtc crc control\n",
155 spin_lock_irq(&crc->lock);
157 if (crc->opened) {
158 spin_unlock_irq(&crc->lock);
163 kfree(crc->source);
164 crc->source = source;
166 spin_unlock_irq(&crc->lock);
181 static int crtc_crc_data_count(struct drm_crtc_crc *crc)
183 assert_spin_locked(&crc->lock);
184 return CIRC_CNT(crc->head, crc->tail, DRM_CRC_ENTRIES_NR);
187 static void crtc_crc_cleanup(struct drm_crtc_crc *crc)
189 kfree(crc->entries);
190 crc->overflow = false;
191 crc->entries = NULL;
192 crc->head = 0;
193 crc->tail = 0;
194 crc->values_cnt = 0;
195 crc->opened = false;
201 struct drm_crtc_crc *crc = &crtc->crc;
219 ret = crtc->funcs->verify_crc_source(crtc, crc->source, &values_cnt);
233 spin_lock_irq(&crc->lock);
234 if (!crc->opened) {
235 crc->opened = true;
236 crc->entries = entries;
237 crc->values_cnt = values_cnt;
241 spin_unlock_irq(&crc->lock);
248 ret = crtc->funcs->set_crc_source(crtc, crc->source);
255 spin_lock_irq(&crc->lock);
256 crtc_crc_cleanup(crc);
257 spin_unlock_irq(&crc->lock);
264 struct drm_crtc_crc *crc = &crtc->crc;
267 spin_lock_irq(&crc->lock);
268 crc->opened = false;
269 spin_unlock_irq(&crc->lock);
273 spin_lock_irq(&crc->lock);
274 crtc_crc_cleanup(crc);
275 spin_unlock_irq(&crc->lock);
281 * 1 frame field of 10 chars plus a number of CRC fields of 10 chars each, space
291 struct drm_crtc_crc *crc = &crtc->crc;
296 spin_lock_irq(&crc->lock);
298 if (!crc->source) {
299 spin_unlock_irq(&crc->lock);
304 while (crtc_crc_data_count(crc) == 0) {
306 spin_unlock_irq(&crc->lock);
310 ret = wait_event_interruptible_lock_irq(crc->wq,
311 crtc_crc_data_count(crc),
312 crc->lock);
314 spin_unlock_irq(&crc->lock);
320 entry = &crc->entries[crc->tail];
322 if (count < LINE_LEN(crc->values_cnt)) {
323 spin_unlock_irq(&crc->lock);
328 crc->tail = (crc->tail + 1) & (DRM_CRC_ENTRIES_NR - 1);
330 spin_unlock_irq(&crc->lock);
337 for (i = 0; i < crc->values_cnt; i++)
339 sprintf(buf + 10 + crc->values_cnt * 11, "\n");
341 if (copy_to_user(user_buf, buf, LINE_LEN(crc->values_cnt)))
344 return LINE_LEN(crc->values_cnt);
350 struct drm_crtc_crc *crc = &crtc->crc;
353 poll_wait(file, &crc->wq, wait);
355 spin_lock_irq(&crc->lock);
356 if (crc->source && crtc_crc_data_count(crc))
358 spin_unlock_irq(&crc->lock);
378 crc_ent = debugfs_create_dir("crc", crtc->debugfs_entry);
387 * drm_crtc_add_crc_entry - Add entry with CRC information for a frame
391 * @crcs: array of CRC values, with length matching #drm_crtc_crc.values_cnt
399 struct drm_crtc_crc *crc = &crtc->crc;
404 spin_lock_irqsave(&crc->lock, flags);
407 if (!crc->entries) {
408 spin_unlock_irqrestore(&crc->lock, flags);
412 head = crc->head;
413 tail = crc->tail;
416 bool was_overflow = crc->overflow;
418 crc->overflow = true;
419 spin_unlock_irqrestore(&crc->lock, flags);
422 DRM_ERROR("Overflow of CRC buffer, userspace reads too slow.\n");
427 entry = &crc->entries[head];
430 memcpy(&entry->crcs, crcs, sizeof(*crcs) * crc->values_cnt);
433 crc->head = head;
435 spin_unlock_irqrestore(&crc->lock, flags);
437 wake_up_interruptible(&crc->wq);