diff --git a/cras/src/server/cras_alsa_io.c b/cras/src/server/cras_alsa_io.c index 520e014bd..10bc4eab8 100644 --- a/cras/src/server/cras_alsa_io.c +++ b/cras/src/server/cras_alsa_io.c @@ -2126,6 +2126,12 @@ static struct alsa_io_group* create_iodev_group(struct cras_iodev* iodev) { return group; } +enum CRAS_USE_CASE get_use_case(const struct cras_iodev* iodev) { + const struct alsa_io* aio = (const struct alsa_io*)iodev; + + return aio->use_case; +} + /* * Exported Interface. */ @@ -2223,6 +2229,7 @@ struct cras_iodev* alsa_iodev_create( iodev->get_dev_group = get_dev_group; iodev->get_dev_group_id = get_dev_group_id; iodev->should_attach_stream = should_attach_stream; + iodev->get_use_case = get_use_case; iodev->get_htimestamp = cras_alsa_common_get_htimestamp; iodev->ramp = cras_ramp_create(); diff --git a/cras/src/server/cras_iodev.h b/cras/src/server/cras_iodev.h index 805e9ea1f..7fcc9b3a4 100644 --- a/cras/src/server/cras_iodev.h +++ b/cras/src/server/cras_iodev.h @@ -17,6 +17,7 @@ #include #include +#include "cras/src/common/cras_types_internal.h" #include "cras/src/server/cras_dsp.h" #include "cras/src/server/cras_nc.h" #include "cras/src/server/ewma_power.h" @@ -282,6 +283,8 @@ struct cras_iodev { // on the iodev's use case and stream parameters. int (*should_attach_stream)(const struct cras_iodev* iodev, const struct cras_rstream* stream); + // (Optional) Gets the use case of the iodev. + enum CRAS_USE_CASE (*get_use_case)(const struct cras_iodev* iodev); // (Optional) Obtain the hardware timestamp for the last update // The hardware timestamp should be using the MONOTONIC_RAW clock // For playback, the timestamp is the last time the iodev wrote into the @@ -1183,6 +1186,21 @@ static inline int cras_iodev_group_has_dev(const struct cras_iodev* iodev, return false; } +/* Gets the use case of the iodev. e.g. HiFi, LowLatency. + * Args: + * iodev - The device + * Returns: + * Use case of the device. + */ +static inline enum CRAS_USE_CASE cras_iodev_get_use_case( + const struct cras_iodev* iodev) { + if (iodev->get_use_case) { + return iodev->get_use_case(iodev); + } + + return CRAS_USE_CASE_HIFI; +} + /* Gets the hardware timestamp of the last update. If there is no hardware * timestamp, returns the current time as the timestamp. * Args: