/**1* Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.2*3* This source file is released under GPL v2 license (no other versions).4* See the COPYING file included in the main directory of this source5* distribution for the license terms and conditions.6*7* @File ctresource.h8*9* @Brief10* This file contains the definition of generic hardware resources for11* resource management.12*13* @Author Liu Chun14* @Date May 13 200815*16*/1718#ifndef CTRESOURCE_H19#define CTRESOURCE_H2021#include <linux/types.h>2223enum RSCTYP {24SRC,25SRCIMP,26AMIXER,27SUM,28DAIO,29NUM_RSCTYP /* This must be the last one and less than 16 */30};3132struct rsc_ops;3334struct rsc {35u32 idx:12; /* The index of a resource */36u32 type:4; /* The type (RSCTYP) of a resource */37u32 conj:12; /* Current conjugate index */38u32 msr:4; /* The Master Sample Rate a resource working on */39void *ctrl_blk; /* Chip specific control info block for a resource */40void *hw; /* Chip specific object for hardware access means */41struct rsc_ops *ops; /* Generic resource operations */42};4344struct rsc_ops {45int (*master)(struct rsc *rsc); /* Move to master resource */46int (*next_conj)(struct rsc *rsc); /* Move to next conjugate resource */47int (*index)(const struct rsc *rsc); /* Return the index of resource */48/* Return the output slot number */49int (*output_slot)(const struct rsc *rsc);50};5152int rsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, void *hw);53int rsc_uninit(struct rsc *rsc);5455struct rsc_mgr {56enum RSCTYP type; /* The type (RSCTYP) of resource to manage */57unsigned int amount; /* The total amount of a kind of resource */58unsigned int avail; /* The amount of currently available resources */59unsigned char *rscs; /* The bit-map for resource allocation */60void *ctrl_blk; /* Chip specific control info block */61void *hw; /* Chip specific object for hardware access */62};6364/* Resource management is based on bit-map mechanism */65int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type,66unsigned int amount, void *hw);67int rsc_mgr_uninit(struct rsc_mgr *mgr);68int mgr_get_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int *ridx);69int mgr_put_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int idx);7071#endif /* CTRESOURCE_H */727374