Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
0004  *
0005  * @File    ctresource.h
0006  *
0007  * @Brief
0008  * This file contains the definition of generic hardware resources for
0009  * resource management.
0010  *
0011  * @Author  Liu Chun
0012  * @Date    May 13 2008
0013  */
0014 
0015 #ifndef CTRESOURCE_H
0016 #define CTRESOURCE_H
0017 
0018 #include <linux/types.h>
0019 
0020 enum RSCTYP {
0021     SRC,
0022     SRCIMP,
0023     AMIXER,
0024     SUM,
0025     DAIO,
0026     NUM_RSCTYP  /* This must be the last one and less than 16 */
0027 };
0028 
0029 struct rsc_ops;
0030 
0031 struct rsc {
0032     u32 idx:12; /* The index of a resource */
0033     u32 type:4; /* The type (RSCTYP) of a resource */
0034     u32 conj:12;    /* Current conjugate index */
0035     u32 msr:4;  /* The Master Sample Rate a resource working on */
0036     void *ctrl_blk; /* Chip specific control info block for a resource */
0037     struct hw *hw;  /* Chip specific object for hardware access means */
0038     const struct rsc_ops *ops;  /* Generic resource operations */
0039 };
0040 
0041 struct rsc_ops {
0042     void (*master)(struct rsc *rsc); /* Move to master resource */
0043     void (*next_conj)(struct rsc *rsc); /* Move to next conjugate resource */
0044     int (*index)(const struct rsc *rsc); /* Return the index of resource */
0045     /* Return the output slot number */
0046     int (*output_slot)(const struct rsc *rsc);
0047 };
0048 
0049 int
0050 rsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, struct hw *hw);
0051 int rsc_uninit(struct rsc *rsc);
0052 
0053 struct rsc_mgr {
0054     enum RSCTYP type; /* The type (RSCTYP) of resource to manage */
0055     unsigned int amount; /* The total amount of a kind of resource */
0056     unsigned int avail; /* The amount of currently available resources */
0057     unsigned char *rscs; /* The bit-map for resource allocation */
0058     void *ctrl_blk; /* Chip specific control info block */
0059     struct hw *hw; /* Chip specific object for hardware access */
0060 };
0061 
0062 /* Resource management is based on bit-map mechanism */
0063 int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type,
0064          unsigned int amount, struct hw *hw);
0065 int rsc_mgr_uninit(struct rsc_mgr *mgr);
0066 int mgr_get_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int *ridx);
0067 int mgr_put_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int idx);
0068 
0069 #endif /* CTRESOURCE_H */