Skip to content

Commit 2a4667f

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: SDCA: Add type flag for Controls
SDCA Controls come in a variety of data formats, to simplify later parsing work out this data type as the control is parsed and stash it for later use. Signed-off-by: Charles Keepax <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 49680c9 commit 2a4667f

File tree

2 files changed

+196
-0
lines changed

2 files changed

+196
-0
lines changed

include/sound/sdca_function.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,27 @@ enum sdca_entity0_controls {
600600
#define SDCA_CTL_DEVICE_VERSION_NAME "Device Version"
601601
#define SDCA_CTL_DEVICE_SDCA_VERSION_NAME "Device SDCA Version"
602602

603+
/**
604+
* enum sdca_control_datatype - SDCA Control Data Types
605+
*
606+
* Data Types as described in the SDCA specification v1.0 section
607+
* 7.3.
608+
*/
609+
enum sdca_control_datatype {
610+
SDCA_CTL_DATATYPE_ONEBIT,
611+
SDCA_CTL_DATATYPE_INTEGER,
612+
SDCA_CTL_DATATYPE_SPEC_ENCODED_VALUE,
613+
SDCA_CTL_DATATYPE_BCD,
614+
SDCA_CTL_DATATYPE_Q7P8DB,
615+
SDCA_CTL_DATATYPE_BYTEINDEX,
616+
SDCA_CTL_DATATYPE_POSTURENUMBER,
617+
SDCA_CTL_DATATYPE_DP_INDEX,
618+
SDCA_CTL_DATATYPE_BITINDEX,
619+
SDCA_CTL_DATATYPE_BITMAP,
620+
SDCA_CTL_DATATYPE_GUID,
621+
SDCA_CTL_DATATYPE_IMPDEF,
622+
};
623+
603624
/**
604625
* enum sdca_access_mode - SDCA Control access mode
605626
*
@@ -653,6 +674,7 @@ struct sdca_control_range {
653674
* @cn_list: A bitmask showing the valid Control Numbers within this Control,
654675
* Control Numbers typically represent channels.
655676
* @range: Buffer describing valid range of values for the Control.
677+
* @type: Format of the data in the Control.
656678
* @mode: Access mode of the Control.
657679
* @layers: Bitmask of access layers of the Control.
658680
* @deferrable: Indicates if the access to the Control can be deferred.
@@ -669,6 +691,7 @@ struct sdca_control {
669691
u64 cn_list;
670692

671693
struct sdca_control_range range;
694+
enum sdca_control_datatype type;
672695
enum sdca_access_mode mode;
673696
u8 layers;
674697

sound/soc/sdca/sdca_functions.c

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,178 @@ static unsigned int find_sdca_control_bits(const struct sdca_entity *entity,
603603
}
604604
}
605605

606+
static enum sdca_control_datatype
607+
find_sdca_control_datatype(const struct sdca_entity *entity,
608+
const struct sdca_control *control)
609+
{
610+
switch (SDCA_CTL_TYPE(entity->type, control->sel)) {
611+
case SDCA_CTL_TYPE_S(XU, BYPASS):
612+
case SDCA_CTL_TYPE_S(MFPU, BYPASS):
613+
case SDCA_CTL_TYPE_S(FU, MUTE):
614+
case SDCA_CTL_TYPE_S(FU, AGC):
615+
case SDCA_CTL_TYPE_S(FU, BASS_BOOST):
616+
case SDCA_CTL_TYPE_S(FU, LOUDNESS):
617+
return SDCA_CTL_DATATYPE_ONEBIT;
618+
case SDCA_CTL_TYPE_S(IT, LATENCY):
619+
case SDCA_CTL_TYPE_S(OT, LATENCY):
620+
case SDCA_CTL_TYPE_S(MU, LATENCY):
621+
case SDCA_CTL_TYPE_S(SU, LATENCY):
622+
case SDCA_CTL_TYPE_S(FU, LATENCY):
623+
case SDCA_CTL_TYPE_S(XU, LATENCY):
624+
case SDCA_CTL_TYPE_S(CRU, LATENCY):
625+
case SDCA_CTL_TYPE_S(UDMPU, LATENCY):
626+
case SDCA_CTL_TYPE_S(MFPU, LATENCY):
627+
case SDCA_CTL_TYPE_S(SMPU, LATENCY):
628+
case SDCA_CTL_TYPE_S(SAPU, LATENCY):
629+
case SDCA_CTL_TYPE_S(PPU, LATENCY):
630+
case SDCA_CTL_TYPE_S(SU, SELECTOR):
631+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_0):
632+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_1):
633+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_2):
634+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_3):
635+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_4):
636+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_5):
637+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_6):
638+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_7):
639+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_8):
640+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_9):
641+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_10):
642+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_11):
643+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_12):
644+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_13):
645+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_14):
646+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_15):
647+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_16):
648+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_17):
649+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_18):
650+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_19):
651+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_20):
652+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_21):
653+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_22):
654+
case SDCA_CTL_TYPE_S(UDMPU, OPAQUESET_23):
655+
case SDCA_CTL_TYPE_S(SAPU, PROTECTION_MODE):
656+
case SDCA_CTL_TYPE_S(SMPU, HIST_BUFFER_PREAMBLE):
657+
case SDCA_CTL_TYPE_S(XU, FDL_HOST_REQUEST):
658+
case SDCA_CTL_TYPE_S(XU, XU_ID):
659+
case SDCA_CTL_TYPE_S(CX, CLOCK_SELECT):
660+
case SDCA_CTL_TYPE_S(TG, TONE_DIVIDER):
661+
case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_MANUFACTURER_ID):
662+
case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_ID):
663+
case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_EXTENSION_ID):
664+
case SDCA_CTL_TYPE_S(ENTITY_0, DEVICE_MANUFACTURER_ID):
665+
case SDCA_CTL_TYPE_S(ENTITY_0, DEVICE_PART_ID):
666+
case SDCA_CTL_TYPE_S(XU, FDL_MESSAGEOFFSET):
667+
case SDCA_CTL_TYPE_S(XU, FDL_MESSAGELENGTH):
668+
case SDCA_CTL_TYPE_S(SPE, AUTHTX_MESSAGEOFFSET):
669+
case SDCA_CTL_TYPE_S(SPE, AUTHTX_MESSAGELENGTH):
670+
case SDCA_CTL_TYPE_S(SPE, AUTHRX_MESSAGEOFFSET):
671+
case SDCA_CTL_TYPE_S(SPE, AUTHRX_MESSAGELENGTH):
672+
case SDCA_CTL_TYPE_S(MFPU, AE_MESSAGEOFFSET):
673+
case SDCA_CTL_TYPE_S(MFPU, AE_MESSAGELENGTH):
674+
case SDCA_CTL_TYPE_S(SMPU, HIST_MESSAGEOFFSET):
675+
case SDCA_CTL_TYPE_S(SMPU, HIST_MESSAGELENGTH):
676+
case SDCA_CTL_TYPE_S(SMPU, DTODTX_MESSAGEOFFSET):
677+
case SDCA_CTL_TYPE_S(SMPU, DTODTX_MESSAGELENGTH):
678+
case SDCA_CTL_TYPE_S(SMPU, DTODRX_MESSAGEOFFSET):
679+
case SDCA_CTL_TYPE_S(SMPU, DTODRX_MESSAGELENGTH):
680+
case SDCA_CTL_TYPE_S(SAPU, DTODTX_MESSAGEOFFSET):
681+
case SDCA_CTL_TYPE_S(SAPU, DTODTX_MESSAGELENGTH):
682+
case SDCA_CTL_TYPE_S(SAPU, DTODRX_MESSAGEOFFSET):
683+
case SDCA_CTL_TYPE_S(SAPU, DTODRX_MESSAGELENGTH):
684+
case SDCA_CTL_TYPE_S(HIDE, HIDTX_MESSAGEOFFSET):
685+
case SDCA_CTL_TYPE_S(HIDE, HIDTX_MESSAGELENGTH):
686+
case SDCA_CTL_TYPE_S(HIDE, HIDRX_MESSAGEOFFSET):
687+
case SDCA_CTL_TYPE_S(HIDE, HIDRX_MESSAGELENGTH):
688+
return SDCA_CTL_DATATYPE_INTEGER;
689+
case SDCA_CTL_TYPE_S(IT, MIC_BIAS):
690+
case SDCA_CTL_TYPE_S(SMPU, HIST_BUFFER_MODE):
691+
case SDCA_CTL_TYPE_S(PDE, REQUESTED_PS):
692+
case SDCA_CTL_TYPE_S(PDE, ACTUAL_PS):
693+
case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_TYPE):
694+
return SDCA_CTL_DATATYPE_SPEC_ENCODED_VALUE;
695+
case SDCA_CTL_TYPE_S(XU, XU_VERSION):
696+
case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_SDCA_VERSION):
697+
case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_VERSION):
698+
case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_EXTENSION_VERSION):
699+
case SDCA_CTL_TYPE_S(ENTITY_0, DEVICE_VERSION):
700+
case SDCA_CTL_TYPE_S(ENTITY_0, DEVICE_SDCA_VERSION):
701+
return SDCA_CTL_DATATYPE_BCD;
702+
case SDCA_CTL_TYPE_S(FU, CHANNEL_VOLUME):
703+
case SDCA_CTL_TYPE_S(FU, GAIN):
704+
case SDCA_CTL_TYPE_S(MU, MIXER):
705+
case SDCA_CTL_TYPE_S(PPU, HORIZONTALBALANCE):
706+
case SDCA_CTL_TYPE_S(PPU, VERTICALBALANCE):
707+
case SDCA_CTL_TYPE_S(MFPU, ULTRASOUND_LEVEL):
708+
case SDCA_CTL_TYPE_S(UDMPU, ACOUSTIC_ENERGY_LEVEL_MONITOR):
709+
case SDCA_CTL_TYPE_S(UDMPU, ULTRASOUND_LOOP_GAIN):
710+
return SDCA_CTL_DATATYPE_Q7P8DB;
711+
case SDCA_CTL_TYPE_S(IT, USAGE):
712+
case SDCA_CTL_TYPE_S(OT, USAGE):
713+
case SDCA_CTL_TYPE_S(IT, CLUSTERINDEX):
714+
case SDCA_CTL_TYPE_S(CRU, CLUSTERINDEX):
715+
case SDCA_CTL_TYPE_S(UDMPU, CLUSTERINDEX):
716+
case SDCA_CTL_TYPE_S(MFPU, CLUSTERINDEX):
717+
case SDCA_CTL_TYPE_S(MFPU, CENTER_FREQUENCY_INDEX):
718+
case SDCA_CTL_TYPE_S(MFPU, AE_NUMBER):
719+
case SDCA_CTL_TYPE_S(SAPU, OPAQUESETREQ_INDEX):
720+
case SDCA_CTL_TYPE_S(XU, FDL_SET_INDEX):
721+
case SDCA_CTL_TYPE_S(CS, SAMPLERATEINDEX):
722+
case SDCA_CTL_TYPE_S(GE, SELECTED_MODE):
723+
case SDCA_CTL_TYPE_S(GE, DETECTED_MODE):
724+
return SDCA_CTL_DATATYPE_BYTEINDEX;
725+
case SDCA_CTL_TYPE_S(PPU, POSTURENUMBER):
726+
return SDCA_CTL_DATATYPE_POSTURENUMBER;
727+
case SDCA_CTL_TYPE_S(IT, DATAPORT_SELECTOR):
728+
case SDCA_CTL_TYPE_S(OT, DATAPORT_SELECTOR):
729+
return SDCA_CTL_DATATYPE_DP_INDEX;
730+
case SDCA_CTL_TYPE_S(MFPU, ALGORITHM_READY):
731+
case SDCA_CTL_TYPE_S(MFPU, ALGORITHM_ENABLE):
732+
case SDCA_CTL_TYPE_S(MFPU, ALGORITHM_PREPARE):
733+
case SDCA_CTL_TYPE_S(SAPU, PROTECTION_STATUS):
734+
case SDCA_CTL_TYPE_S(SMPU, TRIGGER_ENABLE):
735+
case SDCA_CTL_TYPE_S(SMPU, TRIGGER_STATUS):
736+
case SDCA_CTL_TYPE_S(SMPU, TRIGGER_READY):
737+
case SDCA_CTL_TYPE_S(SPE, PRIVACY_POLICY):
738+
case SDCA_CTL_TYPE_S(SPE, PRIVACY_OWNER):
739+
return SDCA_CTL_DATATYPE_BITINDEX;
740+
case SDCA_CTL_TYPE_S(IT, KEEP_ALIVE):
741+
case SDCA_CTL_TYPE_S(OT, KEEP_ALIVE):
742+
case SDCA_CTL_TYPE_S(IT, NDAI_STREAM):
743+
case SDCA_CTL_TYPE_S(OT, NDAI_STREAM):
744+
case SDCA_CTL_TYPE_S(IT, NDAI_CATEGORY):
745+
case SDCA_CTL_TYPE_S(OT, NDAI_CATEGORY):
746+
case SDCA_CTL_TYPE_S(IT, NDAI_CODINGTYPE):
747+
case SDCA_CTL_TYPE_S(OT, NDAI_CODINGTYPE):
748+
case SDCA_CTL_TYPE_S(IT, NDAI_PACKETTYPE):
749+
case SDCA_CTL_TYPE_S(OT, NDAI_PACKETTYPE):
750+
case SDCA_CTL_TYPE_S(SMPU, HIST_ERROR):
751+
case SDCA_CTL_TYPE_S(XU, FDL_STATUS):
752+
case SDCA_CTL_TYPE_S(CS, CLOCK_VALID):
753+
case SDCA_CTL_TYPE_S(SPE, PRIVACY_LOCKSTATE):
754+
case SDCA_CTL_TYPE_S(ENTITY_0, COMMIT_GROUP_MASK):
755+
case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_STATUS):
756+
case SDCA_CTL_TYPE_S(ENTITY_0, FUNCTION_ACTION):
757+
case SDCA_CTL_TYPE_S(XU, FDL_CURRENTOWNER):
758+
case SDCA_CTL_TYPE_S(SPE, AUTHTX_CURRENTOWNER):
759+
case SDCA_CTL_TYPE_S(SPE, AUTHRX_CURRENTOWNER):
760+
case SDCA_CTL_TYPE_S(MFPU, AE_CURRENTOWNER):
761+
case SDCA_CTL_TYPE_S(SMPU, HIST_CURRENTOWNER):
762+
case SDCA_CTL_TYPE_S(SMPU, DTODTX_CURRENTOWNER):
763+
case SDCA_CTL_TYPE_S(SMPU, DTODRX_CURRENTOWNER):
764+
case SDCA_CTL_TYPE_S(SAPU, DTODTX_CURRENTOWNER):
765+
case SDCA_CTL_TYPE_S(SAPU, DTODRX_CURRENTOWNER):
766+
case SDCA_CTL_TYPE_S(HIDE, HIDTX_CURRENTOWNER):
767+
case SDCA_CTL_TYPE_S(HIDE, HIDRX_CURRENTOWNER):
768+
return SDCA_CTL_DATATYPE_BITMAP;
769+
case SDCA_CTL_TYPE_S(IT, MATCHING_GUID):
770+
case SDCA_CTL_TYPE_S(OT, MATCHING_GUID):
771+
case SDCA_CTL_TYPE_S(ENTITY_0, MATCHING_GUID):
772+
return SDCA_CTL_DATATYPE_GUID;
773+
default:
774+
return SDCA_CTL_DATATYPE_IMPDEF;
775+
}
776+
}
777+
606778
static int find_sdca_control_range(struct device *dev,
607779
struct fwnode_handle *control_node,
608780
struct sdca_control_range *range)
@@ -744,6 +916,7 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti
744916
if (!control->label)
745917
return -ENOMEM;
746918

919+
control->type = find_sdca_control_datatype(entity, control);
747920
control->nbits = find_sdca_control_bits(entity, control);
748921

749922
dev_info(dev, "%s: %s: control %#x mode %#x layers %#x cn %#llx int %d value %#x %s\n",

0 commit comments

Comments
 (0)