1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2010 - 2015, Intel Corporation.
5  */
6 
7 #ifndef __QUEUE_ACCESS_H
8 #define __QUEUE_ACCESS_H
9 
10 #include <linux/errno.h>
11 
12 #include <type_support.h>
13 #include <ia_css_queue_comm.h>
14 #include <ia_css_circbuf.h>
15 
16 #define QUEUE_IGNORE_START_FLAG	0x0001
17 #define QUEUE_IGNORE_END_FLAG	0x0002
18 #define QUEUE_IGNORE_SIZE_FLAG	0x0004
19 #define QUEUE_IGNORE_STEP_FLAG	0x0008
20 #define QUEUE_IGNORE_DESC_FLAGS_MAX 0x000f
21 
22 #define QUEUE_IGNORE_SIZE_START_STEP_FLAGS \
23 	(QUEUE_IGNORE_SIZE_FLAG | \
24 	QUEUE_IGNORE_START_FLAG | \
25 	QUEUE_IGNORE_STEP_FLAG)
26 
27 #define QUEUE_IGNORE_SIZE_END_STEP_FLAGS \
28 	(QUEUE_IGNORE_SIZE_FLAG | \
29 	QUEUE_IGNORE_END_FLAG   | \
30 	QUEUE_IGNORE_STEP_FLAG)
31 
32 #define QUEUE_IGNORE_START_END_STEP_FLAGS \
33 	(QUEUE_IGNORE_START_FLAG | \
34 	QUEUE_IGNORE_END_FLAG	  | \
35 	QUEUE_IGNORE_STEP_FLAG)
36 
37 #define QUEUE_CB_DESC_INIT(cb_desc)	\
38 	do {				\
39 		(cb_desc)->size  = 0;	\
40 		(cb_desc)->step  = 0;	\
41 		(cb_desc)->start = 0;	\
42 		(cb_desc)->end   = 0;	\
43 	} while (0)
44 
45 struct ia_css_queue {
46 	u8 type;        /* Specify remote/local type of access */
47 	u8 location;    /* Cell location for queue */
48 	u8 proc_id;     /* Processor id for queue access */
49 	union {
50 		ia_css_circbuf_t cb_local;
51 		struct {
52 			u32 cb_desc_addr; /*Circbuf desc address for remote queues*/
53 			u32 cb_elems_addr; /*Circbuf elements addr for remote queue*/
54 		}	remote;
55 	} desc;
56 };
57 
58 int ia_css_queue_load(
59     struct ia_css_queue *rdesc,
60     ia_css_circbuf_desc_t *cb_desc,
61     uint32_t ignore_desc_flags);
62 
63 int ia_css_queue_store(
64     struct ia_css_queue *rdesc,
65     ia_css_circbuf_desc_t *cb_desc,
66     uint32_t ignore_desc_flags);
67 
68 int ia_css_queue_item_load(
69     struct ia_css_queue *rdesc,
70     u8 position,
71     ia_css_circbuf_elem_t *item);
72 
73 int ia_css_queue_item_store(
74     struct ia_css_queue *rdesc,
75     u8 position,
76     ia_css_circbuf_elem_t *item);
77 
78 #endif /* __QUEUE_ACCESS_H */
79