xref: /openbmc/linux/sound/firewire/cmp.h (revision 0898782247ae533d1f4e47a06bc5d4870931b284)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
231ef9134SClemens Ladisch #ifndef SOUND_FIREWIRE_CMP_H_INCLUDED
331ef9134SClemens Ladisch #define SOUND_FIREWIRE_CMP_H_INCLUDED
431ef9134SClemens Ladisch 
531ef9134SClemens Ladisch #include <linux/mutex.h>
631ef9134SClemens Ladisch #include <linux/types.h>
731ef9134SClemens Ladisch #include "iso-resources.h"
831ef9134SClemens Ladisch 
931ef9134SClemens Ladisch struct fw_unit;
1031ef9134SClemens Ladisch 
11c68a1c65STakashi Sakamoto enum cmp_direction {
12c68a1c65STakashi Sakamoto 	CMP_INPUT = 0,
13c68a1c65STakashi Sakamoto 	CMP_OUTPUT,
14c68a1c65STakashi Sakamoto };
15c68a1c65STakashi Sakamoto 
1631ef9134SClemens Ladisch /**
1731ef9134SClemens Ladisch  * struct cmp_connection - manages an isochronous connection to a device
1831ef9134SClemens Ladisch  * @speed: the connection's actual speed
1931ef9134SClemens Ladisch  *
20a7fa0d04STakashi Sakamoto  * This structure manages (using CMP) an isochronous stream between the local
21a7fa0d04STakashi Sakamoto  * computer and a device's input plug (iPCR) and output plug (oPCR).
2231ef9134SClemens Ladisch  *
2331ef9134SClemens Ladisch  * There is no corresponding oPCR created on the local computer, so it is not
2431ef9134SClemens Ladisch  * possible to overlay connections on top of this one.
2531ef9134SClemens Ladisch  */
2631ef9134SClemens Ladisch struct cmp_connection {
2731ef9134SClemens Ladisch 	int speed;
2831ef9134SClemens Ladisch 	/* private: */
2931ef9134SClemens Ladisch 	bool connected;
3031ef9134SClemens Ladisch 	struct mutex mutex;
3131ef9134SClemens Ladisch 	struct fw_iso_resources resources;
3231ef9134SClemens Ladisch 	__be32 last_pcr_value;
3331ef9134SClemens Ladisch 	unsigned int pcr_index;
3431ef9134SClemens Ladisch 	unsigned int max_speed;
35c68a1c65STakashi Sakamoto 	enum cmp_direction direction;
3631ef9134SClemens Ladisch };
3731ef9134SClemens Ladisch 
3831ef9134SClemens Ladisch int cmp_connection_init(struct cmp_connection *connection,
3931ef9134SClemens Ladisch 			struct fw_unit *unit,
40c68a1c65STakashi Sakamoto 			enum cmp_direction direction,
41a7fa0d04STakashi Sakamoto 			unsigned int pcr_index);
42b04479fbSTakashi Sakamoto int cmp_connection_check_used(struct cmp_connection *connection, bool *used);
4331ef9134SClemens Ladisch void cmp_connection_destroy(struct cmp_connection *connection);
4431ef9134SClemens Ladisch 
45*7bc93821STakashi Sakamoto int cmp_connection_reserve(struct cmp_connection *connection,
4631ef9134SClemens Ladisch 			   unsigned int max_payload);
47*7bc93821STakashi Sakamoto void cmp_connection_release(struct cmp_connection *connection);
48*7bc93821STakashi Sakamoto 
49*7bc93821STakashi Sakamoto int cmp_connection_establish(struct cmp_connection *connection);
5031ef9134SClemens Ladisch int cmp_connection_update(struct cmp_connection *connection);
5131ef9134SClemens Ladisch void cmp_connection_break(struct cmp_connection *connection);
5231ef9134SClemens Ladisch 
5331ef9134SClemens Ladisch #endif
54