summaryrefstree
path: root/kernel/drivers/vision/npu/npu-util-msgidgen.h
blob: 5e0ebe8283a35d0a2e5b0bec1d5214670c48e150 (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
/*
 * Samsung Exynos SoC series NPU driver
 *
 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
 *              http://www.samsung.com/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#ifndef _NPU_UTIL_MSGIDGEN_H_
#define _NPU_UTIL_MSGIDGEN_H_

#include <linux/atomic.h>
#include <linux/time.h>
#include "npu-config.h"

#define MSGID_POOL_MAGIC	0x18D718D7

/* Request ID pool */
struct msgid_pool {
	struct {
		atomic_t occupied;
		int     pt_type;
		void *ref;
#ifdef NPU_MAILBOX_MSG_ID_TIME_KEEPING
		struct  timeval tv_issued;
#endif
	} pool[NPU_MAX_MSG_ID_CNT];
	u32	magic;
};

void msgid_pool_init(struct msgid_pool *handle);
int msgid_issue(struct msgid_pool *handle);
int msgid_issue_save_ref(struct msgid_pool *handle, int pt_type, void *ref);
void msgid_claim(struct msgid_pool *handle, const int msg_id);
void *msgid_claim_get_ref(struct msgid_pool *handle, const int msg_id, const int expected_type);
int msgid_get_pt_type(struct msgid_pool *handle, const int msg_id);
#endif