summaryrefslogtreecommitdiff
path: root/drivers/misc/tegra-profiler/comm.h
blob: e3c7e28719ef80d62fe820a0b0950b324a8d4579 (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
68
69
70
71
72
73
74
75
76
/*
 * drivers/misc/tegra-profiler/comm.h
 *
 * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 */

#ifndef __QUADD_COMM_H__
#define __QUADD_COMM_H__

#include <linux/types.h>

struct quadd_record_data;
struct quadd_comm_cap;
struct quadd_module_state;
struct miscdevice;

struct quadd_ring_buffer {
	char *buf;
	spinlock_t lock;

	size_t size;
	size_t pos_read;
	size_t pos_write;
	size_t fill_count;
};

struct quadd_parameters;

struct quadd_comm_control_interface {
	int (*start)(void);
	void (*stop)(void);
	int (*set_parameters)(struct quadd_parameters *param,
			      uid_t *debug_app_uid);
	void (*get_capabilities)(struct quadd_comm_cap *cap);
	void (*get_state)(struct quadd_module_state *state);
};

struct quadd_comm_data_interface {
	void (*put_sample)(struct quadd_record_data *data, char *extra_data,
			   unsigned int extra_length);
	void (*reset)(void);
};

struct quadd_comm_ctx {
	struct quadd_comm_control_interface *control;

	struct quadd_ring_buffer rb;
	size_t rb_size;

	atomic_t active;

	struct mutex io_mutex;
	int nr_users;

	int params_ok;
	pid_t process_pid;
	uid_t debug_app_uid;

	struct miscdevice *misc_dev;
};

struct quadd_comm_data_interface *
quadd_comm_events_init(struct quadd_comm_control_interface *control);
void quadd_comm_events_exit(void);

#endif	/* __QUADD_COMM_H__ */