xref: /linux/drivers/gpu/drm/xe/xe_guc_klv_helpers.h (revision c5288cda69ee2d8607f5026bd599a5cebf0ee783)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2024 Intel Corporation
4  */
5 
6 #ifndef _XE_GUC_KLV_HELPERS_H_
7 #define _XE_GUC_KLV_HELPERS_H_
8 
9 #include <linux/types.h>
10 
11 struct drm_printer;
12 
13 const char *xe_guc_klv_key_to_string(u16 key);
14 
15 void xe_guc_klv_print(const u32 *klvs, u32 num_dwords, struct drm_printer *p);
16 int xe_guc_klv_count(const u32 *klvs, u32 num_dwords);
17 
18 /**
19  * PREP_GUC_KLV - Prepare KLV header value based on provided key and len.
20  * @key: KLV key
21  * @len: KLV length
22  *
23  * Return: value of the KLV header (u32).
24  */
25 #define PREP_GUC_KLV(key, len) \
26 	(FIELD_PREP(GUC_KLV_0_KEY, (key)) | \
27 	 FIELD_PREP(GUC_KLV_0_LEN, (len)))
28 
29 /**
30  * PREP_GUC_KLV_CONST - Prepare KLV header value based on const key and len.
31  * @key: const KLV key
32  * @len: const KLV length
33  *
34  * Return: value of the KLV header (u32).
35  */
36 #define PREP_GUC_KLV_CONST(key, len) \
37 	(FIELD_PREP_CONST(GUC_KLV_0_KEY, (key)) | \
38 	 FIELD_PREP_CONST(GUC_KLV_0_LEN, (len)))
39 
40 /**
41  * PREP_GUC_KLV_TAG - Prepare KLV header value based on unique KLV definition tag.
42  * @TAG: unique tag of the KLV definition
43  *
44  * Combine separate KEY and LEN definitions of the KLV identified by the TAG.
45  *
46  * Return: value of the KLV header (u32).
47  */
48 #define PREP_GUC_KLV_TAG(TAG) \
49 	PREP_GUC_KLV_CONST(GUC_KLV_##TAG##_KEY, GUC_KLV_##TAG##_LEN)
50 
51 #endif
52