/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.3*4* @File ctresource.h5*6* @Brief7* This file contains the definition of generic hardware resources for8* resource management.9*10* @Author Liu Chun11* @Date May 13 200812*/1314#ifndef CTRESOURCE_H15#define CTRESOURCE_H1617#include <linux/types.h>1819enum RSCTYP {20SRC,21SRCIMP,22AMIXER,23SUM,24DAIO,25NUM_RSCTYP /* This must be the last one and less than 16 */26};2728struct rsc_ops;2930struct rsc {31u32 idx:12; /* The index of a resource */32u32 type:4; /* The type (RSCTYP) of a resource */33u32 conj:12; /* Current conjugate index */34u32 msr:4; /* The Master Sample Rate a resource working on */35void *ctrl_blk; /* Chip specific control info block for a resource */36struct hw *hw; /* Chip specific object for hardware access means */37const struct rsc_ops *ops; /* Generic resource operations */38};3940struct rsc_ops {41void (*master)(struct rsc *rsc); /* Move to master resource */42void (*next_conj)(struct rsc *rsc); /* Move to next conjugate resource */43int (*index)(const struct rsc *rsc); /* Return the index of resource */44/* Return the output slot number */45int (*output_slot)(const struct rsc *rsc);46};4748int49rsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, struct hw *hw);50int rsc_uninit(struct rsc *rsc);5152struct rsc_mgr {53enum RSCTYP type; /* The type (RSCTYP) of resource to manage */54unsigned int amount; /* The total amount of a kind of resource */55unsigned int avail; /* The amount of currently available resources */56unsigned char *rscs; /* The bit-map for resource allocation */57void *ctrl_blk; /* Chip specific control info block */58struct hw *hw; /* Chip specific object for hardware access */59};6061/* Resource management is based on bit-map mechanism */62int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type,63unsigned int amount, struct hw *hw);64int rsc_mgr_uninit(struct rsc_mgr *mgr);65int mgr_get_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int *ridx);66int mgr_put_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int idx);6768#endif /* CTRESOURCE_H */697071