1 // SPDX-License-Identifier: MIT 2 /* Copyright © 2024 Intel Corporation */ 3 4 #include <linux/slab.h> 5 6 #include "i915_drv.h" 7 #include "intel_display_device.h" 8 #include "intel_display_params.h" 9 #include "intel_display_snapshot.h" 10 #include "intel_dmc.h" 11 #include "intel_overlay.h" 12 13 struct intel_display_snapshot { 14 struct intel_display *display; 15 16 struct intel_display_device_info info; 17 struct intel_display_runtime_info runtime_info; 18 struct intel_display_params params; 19 struct intel_overlay_snapshot *overlay; 20 struct intel_dmc_snapshot *dmc; 21 }; 22 23 struct intel_display_snapshot *intel_display_snapshot_capture(struct intel_display *display) 24 { 25 struct intel_display_snapshot *snapshot; 26 27 snapshot = kzalloc(sizeof(*snapshot), GFP_ATOMIC); 28 if (!snapshot) 29 return NULL; 30 31 snapshot->display = display; 32 33 memcpy(&snapshot->info, DISPLAY_INFO(display), sizeof(snapshot->info)); 34 memcpy(&snapshot->runtime_info, DISPLAY_RUNTIME_INFO(display), 35 sizeof(snapshot->runtime_info)); 36 37 intel_display_params_copy(&snapshot->params); 38 39 snapshot->overlay = intel_overlay_snapshot_capture(display); 40 snapshot->dmc = intel_dmc_snapshot_capture(display); 41 42 return snapshot; 43 } 44 45 void intel_display_snapshot_print(const struct intel_display_snapshot *snapshot, 46 struct drm_printer *p) 47 { 48 struct intel_display *display; 49 50 if (!snapshot) 51 return; 52 53 display = snapshot->display; 54 55 intel_display_device_info_print(&snapshot->info, &snapshot->runtime_info, p); 56 intel_display_params_dump(&snapshot->params, display->drm->driver->name, p); 57 58 intel_overlay_snapshot_print(snapshot->overlay, p); 59 intel_dmc_snapshot_print(snapshot->dmc, p); 60 } 61 62 void intel_display_snapshot_free(struct intel_display_snapshot *snapshot) 63 { 64 if (!snapshot) 65 return; 66 67 intel_display_params_free(&snapshot->params); 68 69 kfree(snapshot->overlay); 70 kfree(snapshot->dmc); 71 kfree(snapshot); 72 } 73