1 /* SPDX-License-Identifier: GPL-2.0 or MIT */ 2 3 /* 4 * Copyright (c) 2024 Intel 5 * Copyright (c) 2024 Red Hat 6 */ 7 8 #ifndef __DRM_PANIC_H__ 9 #define __DRM_PANIC_H__ 10 11 #include <linux/types.h> 12 #include <linux/iosys-map.h> 13 14 #include <drm/drm_fourcc.h> 15 16 struct page; 17 18 enum drm_panic_type { 19 DRM_PANIC_TYPE_KMSG, 20 DRM_PANIC_TYPE_USER, 21 DRM_PANIC_TYPE_QR, 22 }; 23 24 /** 25 * struct drm_scanout_buffer - DRM scanout buffer 26 * 27 * This structure holds the information necessary for drm_panic to draw the 28 * panic screen, and display it. 29 */ 30 struct drm_scanout_buffer { 31 /** 32 * @format: 33 * 34 * drm format of the scanout buffer. 35 */ 36 const struct drm_format_info *format; 37 38 /** 39 * @map: 40 * 41 * Virtual address of the scanout buffer, either in memory or iomem. 42 * The scanout buffer should be in linear format, and can be directly 43 * sent to the display hardware. Tearing is not an issue for the panic 44 * screen. 45 */ 46 struct iosys_map map[DRM_FORMAT_MAX_PLANES]; 47 48 /** 49 * @pages: Optional, if the scanout buffer is not mapped, set this field 50 * to the array of pages of the scanout buffer. The panic code will use 51 * kmap_local_page_try_from_panic() to map one page at a time to write 52 * all the pixels. This array shouldn't be allocated from the 53 * get_scanoutbuffer() callback. 54 * The scanout buffer should be in linear format. 55 */ 56 struct page **pages; 57 58 /** 59 * @width: Width of the scanout buffer, in pixels. 60 */ 61 unsigned int width; 62 63 /** 64 * @height: Height of the scanout buffer, in pixels. 65 */ 66 unsigned int height; 67 68 /** 69 * @pitch: Length in bytes between the start of two consecutive lines. 70 */ 71 unsigned int pitch[DRM_FORMAT_MAX_PLANES]; 72 73 /** 74 * @set_pixel: Optional function, to set a pixel color on the 75 * framebuffer. It allows to handle special tiling format inside the 76 * driver. It takes precedence over the @map and @pages fields. 77 */ 78 void (*set_pixel)(struct drm_scanout_buffer *sb, unsigned int x, 79 unsigned int y, u32 color); 80 81 /** 82 * @private: private pointer that you can use in the callbacks 83 * set_pixel() 84 */ 85 void *private; 86 }; 87 88 #endif /* __DRM_PANIC_H__ */ 89