^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * @File ctresource.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * @Brief
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This file contains the definition of generic hardware resources for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * resource management.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * @Author Liu Chun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * @Date May 13 2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #ifndef CTRESOURCE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define CTRESOURCE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) enum RSCTYP {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) SRC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) SRCIMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) AMIXER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) SUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) DAIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) NUM_RSCTYP /* This must be the last one and less than 16 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct rsc_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct rsc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) u32 idx:12; /* The index of a resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) u32 type:4; /* The type (RSCTYP) of a resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) u32 conj:12; /* Current conjugate index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) u32 msr:4; /* The Master Sample Rate a resource working on */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) void *ctrl_blk; /* Chip specific control info block for a resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct hw *hw; /* Chip specific object for hardware access means */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) const struct rsc_ops *ops; /* Generic resource operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct rsc_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) void (*master)(struct rsc *rsc); /* Move to master resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) void (*next_conj)(struct rsc *rsc); /* Move to next conjugate resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) int (*index)(const struct rsc *rsc); /* Return the index of resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* Return the output slot number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int (*output_slot)(const struct rsc *rsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) rsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, struct hw *hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) int rsc_uninit(struct rsc *rsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct rsc_mgr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) enum RSCTYP type; /* The type (RSCTYP) of resource to manage */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) unsigned int amount; /* The total amount of a kind of resource */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) unsigned int avail; /* The amount of currently available resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) unsigned char *rscs; /* The bit-map for resource allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) void *ctrl_blk; /* Chip specific control info block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct hw *hw; /* Chip specific object for hardware access */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /* Resource management is based on bit-map mechanism */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) unsigned int amount, struct hw *hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) int rsc_mgr_uninit(struct rsc_mgr *mgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) int mgr_get_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int *ridx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) int mgr_put_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #endif /* CTRESOURCE_H */