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  * 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 __QUEUE_ACCESS_H
17 #define __QUEUE_ACCESS_H
18 
19 #include <linux/errno.h>
20 
21 #include <type_support.h>
22 #include <ia_css_queue_comm.h>
23 #include <ia_css_circbuf.h>
24 
25 #define QUEUE_IGNORE_START_FLAG	0x0001
26 #define QUEUE_IGNORE_END_FLAG	0x0002
27 #define QUEUE_IGNORE_SIZE_FLAG	0x0004
28 #define QUEUE_IGNORE_STEP_FLAG	0x0008
29 #define QUEUE_IGNORE_DESC_FLAGS_MAX 0x000f
30 
31 #define QUEUE_IGNORE_SIZE_START_STEP_FLAGS \
32 	(QUEUE_IGNORE_SIZE_FLAG | \
33 	QUEUE_IGNORE_START_FLAG | \
34 	QUEUE_IGNORE_STEP_FLAG)
35 
36 #define QUEUE_IGNORE_SIZE_END_STEP_FLAGS \
37 	(QUEUE_IGNORE_SIZE_FLAG | \
38 	QUEUE_IGNORE_END_FLAG   | \
39 	QUEUE_IGNORE_STEP_FLAG)
40 
41 #define QUEUE_IGNORE_START_END_STEP_FLAGS \
42 	(QUEUE_IGNORE_START_FLAG | \
43 	QUEUE_IGNORE_END_FLAG	  | \
44 	QUEUE_IGNORE_STEP_FLAG)
45 
46 #define QUEUE_CB_DESC_INIT(cb_desc)	\
47 	do {				\
48 		(cb_desc)->size  = 0;	\
49 		(cb_desc)->step  = 0;	\
50 		(cb_desc)->start = 0;	\
51 		(cb_desc)->end   = 0;	\
52 	} while (0)
53 
54 struct ia_css_queue {
55 	u8 type;        /* Specify remote/local type of access */
56 	u8 location;    /* Cell location for queue */
57 	u8 proc_id;     /* Processor id for queue access */
58 	union {
59 		ia_css_circbuf_t cb_local;
60 		struct {
61 			u32 cb_desc_addr; /*Circbuf desc address for remote queues*/
62 			u32 cb_elems_addr; /*Circbuf elements addr for remote queue*/
63 		}	remote;
64 	} desc;
65 };
66 
67 int ia_css_queue_load(
68     struct ia_css_queue *rdesc,
69     ia_css_circbuf_desc_t *cb_desc,
70     uint32_t ignore_desc_flags);
71 
72 int ia_css_queue_store(
73     struct ia_css_queue *rdesc,
74     ia_css_circbuf_desc_t *cb_desc,
75     uint32_t ignore_desc_flags);
76 
77 int ia_css_queue_item_load(
78     struct ia_css_queue *rdesc,
79     u8 position,
80     ia_css_circbuf_elem_t *item);
81 
82 int ia_css_queue_item_store(
83     struct ia_css_queue *rdesc,
84     u8 position,
85     ia_css_circbuf_elem_t *item);
86 
87 #endif /* __QUEUE_ACCESS_H */
88