1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2010 - 2015, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  */
14 
15 #ifndef __QUEUE_ACCESS_H
16 #define __QUEUE_ACCESS_H
17 
18 #include <linux/errno.h>
19 
20 #include <type_support.h>
21 #include <ia_css_queue_comm.h>
22 #include <ia_css_circbuf.h>
23 
24 #define QUEUE_IGNORE_START_FLAG	0x0001
25 #define QUEUE_IGNORE_END_FLAG	0x0002
26 #define QUEUE_IGNORE_SIZE_FLAG	0x0004
27 #define QUEUE_IGNORE_STEP_FLAG	0x0008
28 #define QUEUE_IGNORE_DESC_FLAGS_MAX 0x000f
29 
30 #define QUEUE_IGNORE_SIZE_START_STEP_FLAGS \
31 	(QUEUE_IGNORE_SIZE_FLAG | \
32 	QUEUE_IGNORE_START_FLAG | \
33 	QUEUE_IGNORE_STEP_FLAG)
34 
35 #define QUEUE_IGNORE_SIZE_END_STEP_FLAGS \
36 	(QUEUE_IGNORE_SIZE_FLAG | \
37 	QUEUE_IGNORE_END_FLAG   | \
38 	QUEUE_IGNORE_STEP_FLAG)
39 
40 #define QUEUE_IGNORE_START_END_STEP_FLAGS \
41 	(QUEUE_IGNORE_START_FLAG | \
42 	QUEUE_IGNORE_END_FLAG	  | \
43 	QUEUE_IGNORE_STEP_FLAG)
44 
45 #define QUEUE_CB_DESC_INIT(cb_desc)	\
46 	do {				\
47 		(cb_desc)->size  = 0;	\
48 		(cb_desc)->step  = 0;	\
49 		(cb_desc)->start = 0;	\
50 		(cb_desc)->end   = 0;	\
51 	} while (0)
52 
53 struct ia_css_queue {
54 	u8 type;        /* Specify remote/local type of access */
55 	u8 location;    /* Cell location for queue */
56 	u8 proc_id;     /* Processor id for queue access */
57 	union {
58 		ia_css_circbuf_t cb_local;
59 		struct {
60 			u32 cb_desc_addr; /*Circbuf desc address for remote queues*/
61 			u32 cb_elems_addr; /*Circbuf elements addr for remote queue*/
62 		}	remote;
63 	} desc;
64 };
65 
66 int ia_css_queue_load(
67     struct ia_css_queue *rdesc,
68     ia_css_circbuf_desc_t *cb_desc,
69     uint32_t ignore_desc_flags);
70 
71 int ia_css_queue_store(
72     struct ia_css_queue *rdesc,
73     ia_css_circbuf_desc_t *cb_desc,
74     uint32_t ignore_desc_flags);
75 
76 int ia_css_queue_item_load(
77     struct ia_css_queue *rdesc,
78     u8 position,
79     ia_css_circbuf_elem_t *item);
80 
81 int ia_css_queue_item_store(
82     struct ia_css_queue *rdesc,
83     u8 position,
84     ia_css_circbuf_elem_t *item);
85 
86 #endif /* __QUEUE_ACCESS_H */
87