File: utils.h

package info (click to toggle)
intel-gpu-tools 2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 63,360 kB
  • sloc: xml: 781,458; ansic: 360,567; python: 8,336; yacc: 2,781; perl: 1,196; sh: 1,177; lex: 487; asm: 227; lisp: 35; makefile: 30
file content (63 lines) | stat: -rw-r--r-- 1,781 bytes parent folder | download
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
/* SPDX-License-Identifier: MIT */
/*
 * Copyright © 2025 Intel Corporation
 */

#ifndef COMMON_GPUTOP_H
#define COMMON_GPUTOP_H

#include <glib.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

#include "igt_device_scan.h"

#define ANSI_HEADER "\033[7m"
#define ANSI_RESET "\033[0m"

#define PERCLIENT_ENGINE_WIDTH 8

/**
 * struct gputop_driver
 *
 * @device_present: It is set if at least a single device of the
 * respective driver is found.
 * @len: Number of total device discovered of the respective
 * driver.
 * @instances: pointer to the array of discovered instances
 * of the devices of the same driver.
 */
struct gputop_driver {
	bool device_present;
	int len;
	void *instances;
};

/**
 * struct device_operations - Structure to hold function
 * pointers for device specific operations for each individual driver.
 * @gputop_init: Function to initialize GPUTOP object
 * @init_engines: Function to initialize engines for the respective driver.
 * @pmu_init: Function to initialize the PMU (Performance Monitoring Unit).
 * @pmu_sample: Function to sample PMU data.
 * @print_engines: Function to print engine business.
 * @clean_up: Function to release resources.
 */
struct device_operations {
	void (*gputop_init)(void *ptr, int index,
			    struct igt_device_card *card);
	void *(*init_engines)(const void *obj, int index);
	int (*pmu_init)(const void *obj, int index);
	void (*pmu_sample)(const void *obj, int index);
	int (*print_engines)(const void *obj, int index, int lines,
			     int w, int h);
	void (*clean_up)(void *obj, int len);
};

void print_percentage_bar(double percent, int max_len);
int print_engines_footer(int lines, int con_w, int con_h);
void n_spaces(const unsigned int n);

#endif  /* COMMON_GPUTOP_H */