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
27 u16 la; /* lock owner (ARM side) */
28 u16 sa; /* sync word (ARM->DSP) */
29 u16 ld; /* lock owner (DSP side) */
30 u16 sd; /* sync word (DSP->ARM) */
31 unsigned char d[0]; /* data */
36 u16 s; /* sync word */
37 u16 al; /* data address lower */
38 u16 ah; /* data address upper */
41 #define IPBUF_SYS_DLEN 31
44 u16 s; /* sync word */
45 u16 d[IPBUF_SYS_DLEN]; /* data */
53 unsigned long cnt_full; /* count of IPBFULL error */
61 extern struct ipbcfg ipbcfg;
62 extern struct ipbuf_sys *ipbuf_sys_da, *ipbuf_sys_ad;
64 #define ipb_bsycnt_inc(ipbcfg) \
66 disable_mbox_irq(mbox_dsp); \
68 enable_mbox_irq(mbox_dsp); \
71 #define ipb_bsycnt_dec(ipbcfg) \
73 disable_mbox_irq(mbox_dsp); \
75 enable_mbox_irq(mbox_dsp); \
78 #define dsp_mem_enable_ipbuf() dsp_mem_enable(ipbcfg.base)
79 #define dsp_mem_disable_ipbuf() dsp_mem_disable(ipbcfg.base)
87 #define IPBLINK_INIT { \
88 .lock = SPIN_LOCK_UNLOCKED, \
93 #define INIT_IPBLINK(link) \
95 spin_lock_init(&(link)->lock); \
96 (link)->top = BID_NULL; \
97 (link)->tail = BID_NULL; \
100 #define RESET_IPBLINK(link) \
102 (link)->top = BID_NULL; \
103 (link)->tail = BID_NULL; \
106 #define ipblink_empty(link) ((link)->top == BID_NULL)
108 static __inline__ void __ipblink_del_top(struct ipblink *link)
110 struct ipbuf_head *ipb_h = bid_to_ipbuf(link->top);
112 if ((link->top = ipb_h->p->next) == BID_NULL)
113 link->tail = BID_NULL;
115 ipb_h->p->next = BID_NULL;
118 static __inline__ void ipblink_del_top(struct ipblink *link)
120 spin_lock(&link->lock);
121 __ipblink_del_top(link);
122 spin_unlock(&link->lock);
125 static __inline__ void __ipblink_add_tail(struct ipblink *link, u16 bid)
127 if (ipblink_empty(link))
130 bid_to_ipbuf(link->tail)->p->next = bid;
134 static __inline__ void ipblink_add_tail(struct ipblink *link, u16 bid)
136 spin_lock(&link->lock);
137 __ipblink_add_tail(link, bid);
138 spin_unlock(&link->lock);
141 static __inline__ void __ipblink_flush(struct ipblink *link)
145 while (!ipblink_empty(link)) {
147 __ipblink_del_top(link);
148 unuse_ipbuf(bid_to_ipbuf(bid));
152 static __inline__ void ipblink_flush(struct ipblink *link)
154 spin_lock(&link->lock);
155 __ipblink_flush(link);
156 spin_unlock(&link->lock);
159 static __inline__ void __ipblink_add_pvt(struct ipblink *link)
162 link->tail = BID_PVT;
165 static __inline__ void ipblink_add_pvt(struct ipblink *link)
167 spin_lock(&link->lock);
168 __ipblink_add_pvt(link);
169 spin_unlock(&link->lock);
172 static __inline__ void __ipblink_del_pvt(struct ipblink *link)
174 link->top = BID_NULL;
175 link->tail = BID_NULL;
178 static __inline__ void ipblink_del_pvt(struct ipblink *link)
180 spin_lock(&link->lock);
181 __ipblink_del_pvt(link);
182 spin_unlock(&link->lock);
185 static __inline__ void __ipblink_flush_pvt(struct ipblink *link)
187 if (!ipblink_empty(link))
188 ipblink_del_pvt(link);
191 static __inline__ void ipblink_flush_pvt(struct ipblink *link)
193 spin_lock(&link->lock);
194 __ipblink_flush_pvt(link);
195 spin_unlock(&link->lock);
198 #define ipblink_for_each(bid, link) \
199 for (bid = (link)->top; bid != BID_NULL; bid = bid_to_ipbuf(bid)->p->next)