1 1.3 riastrad /* $NetBSD: drm_debugfs_crc.h,v 1.3 2021/12/19 00:46:00 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * Copyright 2016 Collabora Ltd. 5 1.1 riastrad * 6 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 7 1.1 riastrad * copy of this software and associated documentation files (the "Software"), 8 1.1 riastrad * to deal in the Software without restriction, including without limitation 9 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the 11 1.1 riastrad * Software is furnished to do so, subject to the following conditions: 12 1.1 riastrad * 13 1.1 riastrad * The above copyright notice and this permission notice shall be included in 14 1.1 riastrad * all copies or substantial portions of the Software. 15 1.1 riastrad * 16 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 1.1 riastrad * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 1.1 riastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 1.1 riastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 1.1 riastrad * OTHER DEALINGS IN THE SOFTWARE. 23 1.1 riastrad */ 24 1.1 riastrad #ifndef __DRM_DEBUGFS_CRC_H__ 25 1.1 riastrad #define __DRM_DEBUGFS_CRC_H__ 26 1.1 riastrad 27 1.3 riastrad #include <linux/spinlock.h> 28 1.3 riastrad 29 1.3 riastrad struct drm_crtc; 30 1.3 riastrad 31 1.1 riastrad #define DRM_MAX_CRC_NR 10 32 1.1 riastrad 33 1.1 riastrad /** 34 1.1 riastrad * struct drm_crtc_crc_entry - entry describing a frame's content 35 1.1 riastrad * @has_frame_counter: whether the source was able to provide a frame number 36 1.1 riastrad * @frame: number of the frame this CRC is about, if @has_frame_counter is true 37 1.1 riastrad * @crc: array of values that characterize the frame 38 1.1 riastrad */ 39 1.1 riastrad struct drm_crtc_crc_entry { 40 1.1 riastrad bool has_frame_counter; 41 1.1 riastrad uint32_t frame; 42 1.1 riastrad uint32_t crcs[DRM_MAX_CRC_NR]; 43 1.1 riastrad }; 44 1.1 riastrad 45 1.1 riastrad #define DRM_CRC_ENTRIES_NR 128 46 1.1 riastrad 47 1.1 riastrad /** 48 1.1 riastrad * struct drm_crtc_crc - data supporting CRC capture on a given CRTC 49 1.1 riastrad * @lock: protects the fields in this struct 50 1.1 riastrad * @source: name of the currently configured source of CRCs 51 1.1 riastrad * @opened: whether userspace has opened the data file for reading 52 1.1 riastrad * @overflow: whether an overflow occured. 53 1.1 riastrad * @entries: array of entries, with size of %DRM_CRC_ENTRIES_NR 54 1.1 riastrad * @head: head of circular queue 55 1.1 riastrad * @tail: tail of circular queue 56 1.1 riastrad * @values_cnt: number of CRC values per entry, up to %DRM_MAX_CRC_NR 57 1.1 riastrad * @wq: workqueue used to synchronize reading and writing 58 1.1 riastrad */ 59 1.1 riastrad struct drm_crtc_crc { 60 1.1 riastrad spinlock_t lock; 61 1.1 riastrad const char *source; 62 1.1 riastrad bool opened, overflow; 63 1.1 riastrad struct drm_crtc_crc_entry *entries; 64 1.1 riastrad int head, tail; 65 1.1 riastrad size_t values_cnt; 66 1.3 riastrad #ifndef __NetBSD__ 67 1.1 riastrad wait_queue_head_t wq; 68 1.3 riastrad #endif 69 1.1 riastrad }; 70 1.1 riastrad 71 1.1 riastrad #if defined(CONFIG_DEBUG_FS) 72 1.1 riastrad int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame, 73 1.1 riastrad uint32_t frame, uint32_t *crcs); 74 1.1 riastrad #else 75 1.1 riastrad static inline int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame, 76 1.1 riastrad uint32_t frame, uint32_t *crcs) 77 1.1 riastrad { 78 1.1 riastrad return -EINVAL; 79 1.1 riastrad } 80 1.1 riastrad #endif /* defined(CONFIG_DEBUG_FS) */ 81 1.1 riastrad 82 1.1 riastrad #endif /* __DRM_DEBUGFS_CRC_H__ */ 83