xref: /openbmc/linux/sound/pci/ctxfi/ctresource.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
15765e78eSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2a08b9f2fSAditya Srivastava /*
38cc72361SWai Yew CHAY  * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
48cc72361SWai Yew CHAY  *
58cc72361SWai Yew CHAY  * @File	ctresource.h
68cc72361SWai Yew CHAY  *
78cc72361SWai Yew CHAY  * @Brief
88cc72361SWai Yew CHAY  * This file contains the definition of generic hardware resources for
98cc72361SWai Yew CHAY  * resource management.
108cc72361SWai Yew CHAY  *
118cc72361SWai Yew CHAY  * @Author	Liu Chun
128cc72361SWai Yew CHAY  * @Date 	May 13 2008
138cc72361SWai Yew CHAY  */
148cc72361SWai Yew CHAY 
158cc72361SWai Yew CHAY #ifndef CTRESOURCE_H
168cc72361SWai Yew CHAY #define CTRESOURCE_H
178cc72361SWai Yew CHAY 
188cc72361SWai Yew CHAY #include <linux/types.h>
198cc72361SWai Yew CHAY 
208cc72361SWai Yew CHAY enum RSCTYP {
218cc72361SWai Yew CHAY 	SRC,
228cc72361SWai Yew CHAY 	SRCIMP,
238cc72361SWai Yew CHAY 	AMIXER,
248cc72361SWai Yew CHAY 	SUM,
258cc72361SWai Yew CHAY 	DAIO,
268cc72361SWai Yew CHAY 	NUM_RSCTYP	/* This must be the last one and less than 16 */
278cc72361SWai Yew CHAY };
288cc72361SWai Yew CHAY 
298cc72361SWai Yew CHAY struct rsc_ops;
308cc72361SWai Yew CHAY 
318cc72361SWai Yew CHAY struct rsc {
328cc72361SWai Yew CHAY 	u32 idx:12;	/* The index of a resource */
338cc72361SWai Yew CHAY 	u32 type:4;	/* The type (RSCTYP) of a resource */
348cc72361SWai Yew CHAY 	u32 conj:12;	/* Current conjugate index */
358cc72361SWai Yew CHAY 	u32 msr:4;	/* The Master Sample Rate a resource working on */
368cc72361SWai Yew CHAY 	void *ctrl_blk;	/* Chip specific control info block for a resource */
3766640898SSudip Mukherjee 	struct hw *hw;	/* Chip specific object for hardware access means */
3843f2cdebSJulia Lawall 	const struct rsc_ops *ops;	/* Generic resource operations */
398cc72361SWai Yew CHAY };
408cc72361SWai Yew CHAY 
418cc72361SWai Yew CHAY struct rsc_ops {
42*76c47183STakashi Iwai 	void (*master)(struct rsc *rsc); /* Move to master resource */
43*76c47183STakashi Iwai 	void (*next_conj)(struct rsc *rsc); /* Move to next conjugate resource */
448cc72361SWai Yew CHAY 	int (*index)(const struct rsc *rsc); /* Return the index of resource */
458cc72361SWai Yew CHAY 	/* Return the output slot number */
468cc72361SWai Yew CHAY 	int (*output_slot)(const struct rsc *rsc);
478cc72361SWai Yew CHAY };
488cc72361SWai Yew CHAY 
4966640898SSudip Mukherjee int
5066640898SSudip Mukherjee rsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, struct hw *hw);
518cc72361SWai Yew CHAY int rsc_uninit(struct rsc *rsc);
528cc72361SWai Yew CHAY 
538cc72361SWai Yew CHAY struct rsc_mgr {
548cc72361SWai Yew CHAY 	enum RSCTYP type; /* The type (RSCTYP) of resource to manage */
558cc72361SWai Yew CHAY 	unsigned int amount; /* The total amount of a kind of resource */
568cc72361SWai Yew CHAY 	unsigned int avail; /* The amount of currently available resources */
578cc72361SWai Yew CHAY 	unsigned char *rscs; /* The bit-map for resource allocation */
588cc72361SWai Yew CHAY 	void *ctrl_blk; /* Chip specific control info block */
5966640898SSudip Mukherjee 	struct hw *hw; /* Chip specific object for hardware access */
608cc72361SWai Yew CHAY };
618cc72361SWai Yew CHAY 
628cc72361SWai Yew CHAY /* Resource management is based on bit-map mechanism */
638cc72361SWai Yew CHAY int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type,
6466640898SSudip Mukherjee 		 unsigned int amount, struct hw *hw);
658cc72361SWai Yew CHAY int rsc_mgr_uninit(struct rsc_mgr *mgr);
668cc72361SWai Yew CHAY int mgr_get_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int *ridx);
678cc72361SWai Yew CHAY int mgr_put_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int idx);
688cc72361SWai Yew CHAY 
698cc72361SWai Yew CHAY #endif /* CTRESOURCE_H */
70