^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef SOUND_FIREWIRE_CMP_H_INCLUDED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define SOUND_FIREWIRE_CMP_H_INCLUDED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include "iso-resources.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) struct fw_unit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) enum cmp_direction {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) CMP_INPUT = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) CMP_OUTPUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * struct cmp_connection - manages an isochronous connection to a device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * @speed: the connection's actual speed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * This structure manages (using CMP) an isochronous stream between the local
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * computer and a device's input plug (iPCR) and output plug (oPCR).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * There is no corresponding oPCR created on the local computer, so it is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * possible to overlay connections on top of this one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct cmp_connection {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /* private: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) bool connected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct fw_iso_resources resources;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) __be32 last_pcr_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) unsigned int pcr_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) unsigned int max_speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) enum cmp_direction direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) int cmp_connection_init(struct cmp_connection *connection,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct fw_unit *unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) enum cmp_direction direction,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) unsigned int pcr_index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int cmp_connection_check_used(struct cmp_connection *connection, bool *used);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) void cmp_connection_destroy(struct cmp_connection *connection);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) int cmp_connection_reserve(struct cmp_connection *connection,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) unsigned int max_payload);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) void cmp_connection_release(struct cmp_connection *connection);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int cmp_connection_establish(struct cmp_connection *connection);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int cmp_connection_update(struct cmp_connection *connection);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) void cmp_connection_break(struct cmp_connection *connection);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #endif