Lines Matching +full:multi +full:- +full:bit

1 // SPDX-License-Identifier: GPL-2.0-only
21 /* Resource allocation based on bit-map management mechanism */
24 unsigned int multi, unsigned int *ridx) in get_resource() argument
29 for (i = 0, n = multi; i < amount; i++) { in get_resource()
33 n = multi; in get_resource()
36 if (!(--n)) in get_resource()
42 return -ENOENT; in get_resource()
45 /* Mark the contiguous bits in resource bit-map as used */ in get_resource()
46 for (n = multi; n > 0; n--) { in get_resource()
50 i--; in get_resource()
58 static int put_resource(u8 *rscs, unsigned int multi, unsigned int idx) in put_resource() argument
62 /* Mark the contiguous bits in resource bit-map as used */ in put_resource()
63 for (n = multi, i = idx; n > 0; n--) { in put_resource()
77 if (n > mgr->avail) in mgr_get_resource()
78 return -ENOENT; in mgr_get_resource()
80 err = get_resource(mgr->rscs, mgr->amount, n, ridx); in mgr_get_resource()
82 mgr->avail -= n; in mgr_get_resource()
89 put_resource(mgr->rscs, n, idx); in mgr_put_resource()
90 mgr->avail += n; in mgr_put_resource()
104 return rsc->conj; in rsc_index()
109 return (rsc->conj << 4) + offset_in_audio_slot_block[rsc->type]; in audio_ring_slot()
115 for (i = 0; (i < 8) && (!(rsc->msr & (0x1 << i))); ) in rsc_next_conj()
117 rsc->conj += (AUDIO_SLOT_BLOCK_NUM >> i); in rsc_next_conj()
122 rsc->conj = rsc->idx; in rsc_master()
137 rsc->idx = idx; in rsc_init()
138 rsc->conj = idx; in rsc_init()
139 rsc->type = type; in rsc_init()
140 rsc->msr = msr; in rsc_init()
141 rsc->hw = hw; in rsc_init()
142 rsc->ops = &rsc_generic_ops; in rsc_init()
144 rsc->ctrl_blk = NULL; in rsc_init()
150 err = hw->src_rsc_get_ctrl_blk(&rsc->ctrl_blk); in rsc_init()
153 err = hw->amixer_rsc_get_ctrl_blk(&rsc->ctrl_blk); in rsc_init()
160 dev_err(((struct hw *)hw)->card->dev, in rsc_init()
162 return -EINVAL; in rsc_init()
166 dev_err(((struct hw *)hw)->card->dev, in rsc_init()
176 if ((NULL != rsc->hw) && (NULL != rsc->ctrl_blk)) { in rsc_uninit()
177 switch (rsc->type) { in rsc_uninit()
179 rsc->hw->src_rsc_put_ctrl_blk(rsc->ctrl_blk); in rsc_uninit()
182 rsc->hw->amixer_rsc_put_ctrl_blk(rsc->ctrl_blk); in rsc_uninit()
188 dev_err(((struct hw *)rsc->hw)->card->dev, in rsc_uninit()
190 rsc->type); in rsc_uninit()
194 rsc->hw = rsc->ctrl_blk = NULL; in rsc_uninit()
197 rsc->idx = rsc->conj = 0; in rsc_uninit()
198 rsc->type = NUM_RSCTYP; in rsc_uninit()
199 rsc->msr = 0; in rsc_uninit()
209 mgr->type = NUM_RSCTYP; in rsc_mgr_init()
211 mgr->rscs = kzalloc(DIV_ROUND_UP(amount, 8), GFP_KERNEL); in rsc_mgr_init()
212 if (!mgr->rscs) in rsc_mgr_init()
213 return -ENOMEM; in rsc_mgr_init()
217 err = hw->src_mgr_get_ctrl_blk(&mgr->ctrl_blk); in rsc_mgr_init()
220 err = hw->srcimp_mgr_get_ctrl_blk(&mgr->ctrl_blk); in rsc_mgr_init()
223 err = hw->amixer_mgr_get_ctrl_blk(&mgr->ctrl_blk); in rsc_mgr_init()
226 err = hw->daio_mgr_get_ctrl_blk(hw, &mgr->ctrl_blk); in rsc_mgr_init()
231 dev_err(hw->card->dev, in rsc_mgr_init()
233 err = -EINVAL; in rsc_mgr_init()
238 dev_err(hw->card->dev, in rsc_mgr_init()
243 mgr->type = type; in rsc_mgr_init()
244 mgr->avail = mgr->amount = amount; in rsc_mgr_init()
245 mgr->hw = hw; in rsc_mgr_init()
250 kfree(mgr->rscs); in rsc_mgr_init()
256 kfree(mgr->rscs); in rsc_mgr_uninit()
257 mgr->rscs = NULL; in rsc_mgr_uninit()
259 if ((NULL != mgr->hw) && (NULL != mgr->ctrl_blk)) { in rsc_mgr_uninit()
260 switch (mgr->type) { in rsc_mgr_uninit()
262 mgr->hw->src_mgr_put_ctrl_blk(mgr->ctrl_blk); in rsc_mgr_uninit()
265 mgr->hw->srcimp_mgr_put_ctrl_blk(mgr->ctrl_blk); in rsc_mgr_uninit()
268 mgr->hw->amixer_mgr_put_ctrl_blk(mgr->ctrl_blk); in rsc_mgr_uninit()
271 mgr->hw->daio_mgr_put_ctrl_blk(mgr->ctrl_blk); in rsc_mgr_uninit()
276 dev_err(((struct hw *)mgr->hw)->card->dev, in rsc_mgr_uninit()
278 mgr->type); in rsc_mgr_uninit()
282 mgr->hw = mgr->ctrl_blk = NULL; in rsc_mgr_uninit()
285 mgr->type = NUM_RSCTYP; in rsc_mgr_uninit()
286 mgr->avail = mgr->amount = 0; in rsc_mgr_uninit()