Linux Audio

Check our new training course

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