2 * This file is part of OMAP DSP driver (DSP Gateway version 3.3.1)
4 * Copyright (C) 2002-2006 Nokia Corporation. All rights reserved.
6 * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #ifndef __PLAT_OMAP_DSP_IPBUF_H
25 #define __PLAT_OMAP_DSP_IPBUF_H
30 u16 la; /* lock owner (ARM side) */
31 u16 sa; /* sync word (ARM->DSP) */
32 u16 ld; /* lock owner (DSP side) */
33 u16 sd; /* sync word (DSP->ARM) */
34 unsigned char d[0]; /* data */
39 u16 s; /* sync word */
40 u16 al; /* data address lower */
41 u16 ah; /* data address upper */
44 #define IPBUF_SYS_DLEN 31
47 u16 s; /* sync word */
48 u16 d[IPBUF_SYS_DLEN]; /* data */
56 unsigned long cnt_full; /* count of IPBFULL error */
64 extern struct ipbcfg ipbcfg;
65 extern struct ipbuf_sys *ipbuf_sys_da, *ipbuf_sys_ad;
67 #define ipb_bsycnt_inc(ipbcfg) atomic_inc((atomic_t *)&((ipbcfg)->bsycnt))
68 #define ipb_bsycnt_dec(ipbcfg) atomic_dec((atomic_t *)&((ipbcfg)->bsycnt))
70 #define dsp_mem_enable_ipbuf() dsp_mem_enable(ipbcfg.base)
71 #define dsp_mem_disable_ipbuf() dsp_mem_disable(ipbcfg.base)
79 #define IPBLINK_INIT { \
80 .lock = SPIN_LOCK_UNLOCKED, \
85 #define INIT_IPBLINK(link) \
87 spin_lock_init(&(link)->lock); \
88 (link)->top = BID_NULL; \
89 (link)->tail = BID_NULL; \
92 #define RESET_IPBLINK(link) \
94 (link)->top = BID_NULL; \
95 (link)->tail = BID_NULL; \
98 #define ipblink_empty(link) ((link)->top == BID_NULL)
100 static inline void __ipblink_del_top(struct ipblink *link)
102 struct ipbuf_head *ipb_h = bid_to_ipbuf(link->top);
104 if ((link->top = ipb_h->p->next) == BID_NULL)
105 link->tail = BID_NULL;
107 ipb_h->p->next = BID_NULL;
110 static inline void ipblink_del_top(struct ipblink *link)
112 spin_lock(&link->lock);
113 __ipblink_del_top(link);
114 spin_unlock(&link->lock);
117 static inline void __ipblink_add_tail(struct ipblink *link, u16 bid)
119 if (ipblink_empty(link))
122 bid_to_ipbuf(link->tail)->p->next = bid;
126 static inline void ipblink_add_tail(struct ipblink *link, u16 bid)
128 spin_lock(&link->lock);
129 __ipblink_add_tail(link, bid);
130 spin_unlock(&link->lock);
133 static inline void __ipblink_flush(struct ipblink *link)
137 while (!ipblink_empty(link)) {
139 __ipblink_del_top(link);
140 unuse_ipbuf(bid_to_ipbuf(bid));
144 static inline void ipblink_flush(struct ipblink *link)
146 spin_lock(&link->lock);
147 __ipblink_flush(link);
148 spin_unlock(&link->lock);
151 static inline void __ipblink_add_pvt(struct ipblink *link)
154 link->tail = BID_PVT;
157 static inline void ipblink_add_pvt(struct ipblink *link)
159 spin_lock(&link->lock);
160 __ipblink_add_pvt(link);
161 spin_unlock(&link->lock);
164 static inline void __ipblink_del_pvt(struct ipblink *link)
166 link->top = BID_NULL;
167 link->tail = BID_NULL;
170 static inline void ipblink_del_pvt(struct ipblink *link)
172 spin_lock(&link->lock);
173 __ipblink_del_pvt(link);
174 spin_unlock(&link->lock);
177 static inline void __ipblink_flush_pvt(struct ipblink *link)
179 if (!ipblink_empty(link))
180 ipblink_del_pvt(link);
183 static inline void ipblink_flush_pvt(struct ipblink *link)
185 spin_lock(&link->lock);
186 __ipblink_flush_pvt(link);
187 spin_unlock(&link->lock);
190 #define ipblink_for_each(bid, link) \
191 for (bid = (link)->top; bid != BID_NULL; bid = bid_to_ipbuf(bid)->p->next)
193 #endif /* __PLAT_OMAP_DSP_IPBUF_H */