xref: /OK3568_Linux_fs/kernel/sound/firewire/iso-resources.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef SOUND_FIREWIRE_ISO_RESOURCES_H_INCLUDED
3*4882a593Smuzhiyun #define SOUND_FIREWIRE_ISO_RESOURCES_H_INCLUDED
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/mutex.h>
6*4882a593Smuzhiyun #include <linux/types.h>
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun struct fw_unit;
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun /**
11*4882a593Smuzhiyun  * struct fw_iso_resources - manages channel/bandwidth allocation
12*4882a593Smuzhiyun  * @channels_mask: if the device does not support all channel numbers, set this
13*4882a593Smuzhiyun  *                 bit mask to something else than the default (all ones)
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * This structure manages (de)allocation of isochronous resources (channel and
16*4882a593Smuzhiyun  * bandwidth) for one isochronous stream.
17*4882a593Smuzhiyun  */
18*4882a593Smuzhiyun struct fw_iso_resources {
19*4882a593Smuzhiyun 	u64 channels_mask;
20*4882a593Smuzhiyun 	/* private: */
21*4882a593Smuzhiyun 	struct fw_unit *unit;
22*4882a593Smuzhiyun 	struct mutex mutex;
23*4882a593Smuzhiyun 	unsigned int channel;
24*4882a593Smuzhiyun 	unsigned int bandwidth; /* in bandwidth units, without overhead */
25*4882a593Smuzhiyun 	unsigned int bandwidth_overhead;
26*4882a593Smuzhiyun 	int generation; /* in which allocation is valid */
27*4882a593Smuzhiyun 	bool allocated;
28*4882a593Smuzhiyun };
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun int fw_iso_resources_init(struct fw_iso_resources *r,
31*4882a593Smuzhiyun 			  struct fw_unit *unit);
32*4882a593Smuzhiyun void fw_iso_resources_destroy(struct fw_iso_resources *r);
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun int fw_iso_resources_allocate(struct fw_iso_resources *r,
35*4882a593Smuzhiyun 			      unsigned int max_payload_bytes, int speed);
36*4882a593Smuzhiyun int fw_iso_resources_update(struct fw_iso_resources *r);
37*4882a593Smuzhiyun void fw_iso_resources_free(struct fw_iso_resources *r);
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #endif
40