summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/display/intel_display_snapshot.c
blob: a61ff0f813972b3f9089eb143d850bcdc1de3b3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// SPDX-License-Identifier: MIT
/* Copyright © 2024 Intel Corporation */

#include <linux/slab.h>

#include "i915_drv.h"
#include "intel_display_device.h"
#include "intel_display_params.h"
#include "intel_display_snapshot.h"
#include "intel_overlay.h"

struct intel_display_snapshot {
	struct intel_display *display;

	struct intel_display_device_info info;
	struct intel_display_runtime_info runtime_info;
	struct intel_display_params params;
	struct intel_overlay_snapshot *overlay;
};

struct intel_display_snapshot *intel_display_snapshot_capture(struct intel_display *display)
{
	struct intel_display_snapshot *snapshot;

	snapshot = kzalloc(sizeof(*snapshot), GFP_ATOMIC);
	if (!snapshot)
		return NULL;

	snapshot->display = display;

	memcpy(&snapshot->info, DISPLAY_INFO(display), sizeof(snapshot->info));
	memcpy(&snapshot->runtime_info, DISPLAY_RUNTIME_INFO(display),
	       sizeof(snapshot->runtime_info));

	intel_display_params_copy(&snapshot->params);

	snapshot->overlay = intel_overlay_snapshot_capture(display);

	return snapshot;
}

void intel_display_snapshot_print(const struct intel_display_snapshot *snapshot,
				  struct drm_printer *p)
{
	struct intel_display *display;

	if (!snapshot)
		return;

	display = snapshot->display;

	intel_display_device_info_print(&snapshot->info, &snapshot->runtime_info, p);
	intel_display_params_dump(&snapshot->params, display->drm->driver->name, p);

	intel_overlay_snapshot_print(snapshot->overlay, p);
}

void intel_display_snapshot_free(struct intel_display_snapshot *snapshot)
{
	if (!snapshot)
		return;

	intel_display_params_free(&snapshot->params);

	kfree(snapshot->overlay);
	kfree(snapshot);
}