21 #include <linux/slab.h>
23 #define AUDIO_SLOT_BLOCK_NUM 256
27 get_resource(
u8 *rscs,
unsigned int amount,
28 unsigned int multi,
unsigned int *ridx)
33 for (i = 0, n = multi; i < amount; i++) {
36 if (rscs[j] & ((
u8)1 << k)) {
50 for (n = multi; n > 0; n--) {
53 rscs[
j] |= ((
u8)1 << k);
62 static int put_resource(
u8 *rscs,
unsigned int multi,
unsigned int idx)
64 unsigned int i,
j,
k,
n;
67 for (n = multi, i = idx; n > 0; n--) {
70 rscs[
j] &= ~((
u8)1 << k);
84 err = get_resource(mgr->
rscs, mgr->
amount, n, ridx);
93 put_resource(mgr->
rscs, n, idx);
99 static unsigned char offset_in_audio_slot_block[
NUM_RSCTYP] = {
106 static int rsc_index(
const struct rsc *
rsc)
111 static int audio_ring_slot(
const struct rsc *
rsc)
113 return (rsc->
conj << 4) + offset_in_audio_slot_block[rsc->
type];
116 static int rsc_next_conj(
struct rsc *rsc)
119 for (i = 0; (i < 8) && (!(rsc->
msr & (0x1 << i))); )
125 static int rsc_master(
struct rsc *rsc)
130 static struct rsc_ops rsc_generic_ops = {
132 .output_slot = audio_ring_slot,
133 .master = rsc_master,
134 .next_conj = rsc_next_conj,
146 rsc->
ops = &rsc_generic_ops;
154 err = ((
struct hw *)hw)->src_rsc_get_ctrl_blk(&rsc->
ctrl_blk);
157 err = ((
struct hw *)hw)->
166 "ctxfi: Invalid resource type value %d!\n", type);
172 "ctxfi: Failed to get resource control block!\n");
184 ((
struct hw *)rsc->
hw)->
188 ((
struct hw *)rsc->
hw)->
196 "Invalid resource type value %d!\n", rsc->
type);
211 unsigned int amount,
void *hw_obj)
214 struct hw *
hw = hw_obj;
239 "ctxfi: Invalid resource type value %d!\n", type);
246 "ctxfi: Failed to get manager control block!\n");
271 ((
struct hw *)mgr->
hw)->
275 ((
struct hw *)mgr->
hw)->
279 ((
struct hw *)mgr->
hw)->
283 ((
struct hw *)mgr->
hw)->
290 "Invalid resource type value %d!\n", mgr->
type);