xref: /linux/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/event_fifo_private.h (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 
16 #ifndef __EVENT_FIFO_PRIVATE_H
17 #define __EVENT_FIFO_PRIVATE_H
18 
19 #include "event_fifo_public.h"
20 
21 #include "device_access.h"
22 
23 #include "assert_support.h"
24 
25 #include <bits.h>			/* _hrt_get_bits() */
26 
event_wait_for(const event_ID_t ID)27 STORAGE_CLASS_EVENT_C void event_wait_for(const event_ID_t ID)
28 {
29 	assert(ID < N_EVENT_ID);
30 	assert(event_source_addr[ID] != ((hrt_address) - 1));
31 	(void)ia_css_device_load_uint32(event_source_addr[ID]);
32 	return;
33 }
34 
cnd_event_wait_for(const event_ID_t ID,const bool cnd)35 STORAGE_CLASS_EVENT_C void cnd_event_wait_for(const event_ID_t ID,
36 	const bool cnd)
37 {
38 	if (cnd) {
39 		event_wait_for(ID);
40 	}
41 }
42 
event_receive_token(const event_ID_t ID)43 STORAGE_CLASS_EVENT_C hrt_data event_receive_token(const event_ID_t ID)
44 {
45 	assert(ID < N_EVENT_ID);
46 	assert(event_source_addr[ID] != ((hrt_address) - 1));
47 	return ia_css_device_load_uint32(event_source_addr[ID]);
48 }
49 
event_send_token(const event_ID_t ID,const hrt_data token)50 STORAGE_CLASS_EVENT_C void event_send_token(const event_ID_t ID,
51 	const hrt_data token)
52 {
53 	assert(ID < N_EVENT_ID);
54 	assert(event_sink_addr[ID] != ((hrt_address) - 1));
55 	ia_css_device_store_uint32(event_sink_addr[ID], token);
56 }
57 
is_event_pending(const event_ID_t ID)58 STORAGE_CLASS_EVENT_C bool is_event_pending(const event_ID_t ID)
59 {
60 	hrt_data	value;
61 
62 	assert(ID < N_EVENT_ID);
63 	assert(event_source_query_addr[ID] != ((hrt_address) - 1));
64 	value = ia_css_device_load_uint32(event_source_query_addr[ID]);
65 	return !_hrt_get_bit(value, EVENT_QUERY_BIT);
66 }
67 
can_event_send_token(const event_ID_t ID)68 STORAGE_CLASS_EVENT_C bool can_event_send_token(const event_ID_t ID)
69 {
70 	hrt_data	value;
71 
72 	assert(ID < N_EVENT_ID);
73 	assert(event_sink_query_addr[ID] != ((hrt_address) - 1));
74 	value = ia_css_device_load_uint32(event_sink_query_addr[ID]);
75 	return !_hrt_get_bit(value, EVENT_QUERY_BIT);
76 }
77 
78 #endif /* __EVENT_FIFO_PRIVATE_H */
79