/*1* Copyright © 2016 Collabora Ltd.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR17* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19* OTHER DEALINGS IN THE SOFTWARE.20*/21#ifndef __DRM_DEBUGFS_CRC_H__22#define __DRM_DEBUGFS_CRC_H__2324#include <linux/spinlock_types.h>25#include <linux/types.h>26#include <linux/wait.h>2728struct drm_crtc;2930#define DRM_MAX_CRC_NR 103132/**33* struct drm_crtc_crc_entry - entry describing a frame's content34* @has_frame_counter: whether the source was able to provide a frame number35* @frame: number of the frame this CRC is about, if @has_frame_counter is true36* @crcs: array of values that characterize the frame37*/38struct drm_crtc_crc_entry {39bool has_frame_counter;40uint32_t frame;41uint32_t crcs[DRM_MAX_CRC_NR];42};4344#define DRM_CRC_ENTRIES_NR 1284546/**47* struct drm_crtc_crc - data supporting CRC capture on a given CRTC48* @lock: protects the fields in this struct49* @source: name of the currently configured source of CRCs50* @opened: whether userspace has opened the data file for reading51* @overflow: whether an overflow occured.52* @entries: array of entries, with size of %DRM_CRC_ENTRIES_NR53* @head: head of circular queue54* @tail: tail of circular queue55* @values_cnt: number of CRC values per entry, up to %DRM_MAX_CRC_NR56* @wq: workqueue used to synchronize reading and writing57*/58struct drm_crtc_crc {59spinlock_t lock;60const char *source;61bool opened, overflow;62struct drm_crtc_crc_entry *entries;63int head, tail;64size_t values_cnt;65wait_queue_head_t wq;66};6768#if defined(CONFIG_DEBUG_FS)69int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame,70uint32_t frame, uint32_t *crcs);71#else72static inline int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame,73uint32_t frame, uint32_t *crcs)74{75return -EINVAL;76}77#endif /* defined(CONFIG_DEBUG_FS) */7879#endif /* __DRM_DEBUGFS_CRC_H__ */808182