@@ -44,6 +44,11 @@ struct sdca_function_desc;
44
44
*/
45
45
#define SDCA_MAX_DELAY_COUNT 256
46
46
47
+ /*
48
+ * Sanity check on size of affected controls data, can be expanded if needed.
49
+ */
50
+ #define SDCA_MAX_AFFECTED_COUNT 2048
51
+
47
52
/**
48
53
* enum sdca_function_type - SDCA Function Type codes
49
54
* @SDCA_FUNCTION_TYPE_SMART_AMP: Amplifier with protection features.
@@ -600,6 +605,27 @@ enum sdca_entity0_controls {
600
605
#define SDCA_CTL_DEVICE_VERSION_NAME "Device Version"
601
606
#define SDCA_CTL_DEVICE_SDCA_VERSION_NAME "Device SDCA Version"
602
607
608
+ /**
609
+ * enum sdca_control_datatype - SDCA Control Data Types
610
+ *
611
+ * Data Types as described in the SDCA specification v1.0 section
612
+ * 7.3.
613
+ */
614
+ enum sdca_control_datatype {
615
+ SDCA_CTL_DATATYPE_ONEBIT ,
616
+ SDCA_CTL_DATATYPE_INTEGER ,
617
+ SDCA_CTL_DATATYPE_SPEC_ENCODED_VALUE ,
618
+ SDCA_CTL_DATATYPE_BCD ,
619
+ SDCA_CTL_DATATYPE_Q7P8DB ,
620
+ SDCA_CTL_DATATYPE_BYTEINDEX ,
621
+ SDCA_CTL_DATATYPE_POSTURENUMBER ,
622
+ SDCA_CTL_DATATYPE_DP_INDEX ,
623
+ SDCA_CTL_DATATYPE_BITINDEX ,
624
+ SDCA_CTL_DATATYPE_BITMAP ,
625
+ SDCA_CTL_DATATYPE_GUID ,
626
+ SDCA_CTL_DATATYPE_IMPDEF ,
627
+ };
628
+
603
629
/**
604
630
* enum sdca_access_mode - SDCA Control access mode
605
631
*
@@ -653,6 +679,7 @@ struct sdca_control_range {
653
679
* @cn_list: A bitmask showing the valid Control Numbers within this Control,
654
680
* Control Numbers typically represent channels.
655
681
* @range: Buffer describing valid range of values for the Control.
682
+ * @type: Format of the data in the Control.
656
683
* @mode: Access mode of the Control.
657
684
* @layers: Bitmask of access layers of the Control.
658
685
* @deferrable: Indicates if the access to the Control can be deferred.
@@ -669,6 +696,7 @@ struct sdca_control {
669
696
u64 cn_list ;
670
697
671
698
struct sdca_control_range range ;
699
+ enum sdca_control_datatype type ;
672
700
enum sdca_access_mode mode ;
673
701
u8 layers ;
674
702
@@ -904,11 +932,51 @@ enum sdca_entity_type {
904
932
SDCA_ENTITY_TYPE_HIDE = 0x31 ,
905
933
};
906
934
935
+ /**
936
+ * struct sdca_ge_control - control entry in the affected controls list
937
+ * @id: Entity ID of the Control affected.
938
+ * @sel: Control Selector of the Control affected.
939
+ * @cn: Control Number of the Control affected.
940
+ * @val: Value written to Control for this Mode.
941
+ */
942
+ struct sdca_ge_control {
943
+ int id ;
944
+ int sel ;
945
+ int cn ;
946
+ int val ;
947
+ };
948
+
949
+ /**
950
+ * struct sdca_ge_mode - mode entry in the affected controls list
951
+ * @controls: Dynamically allocated array of controls written for this Mode.
952
+ * @num_controls: Number of controls written in this Mode.
953
+ * @val: GE Selector Mode value.
954
+ */
955
+ struct sdca_ge_mode {
956
+ struct sdca_ge_control * controls ;
957
+ int num_controls ;
958
+ int val ;
959
+ };
960
+
961
+ /**
962
+ * struct sdca_entity_ge - information specific to Group Entities
963
+ * @kctl: ALSA control pointer that can be used by linked Entities.
964
+ * @modes: Dynamically allocated array of Modes and the Controls written
965
+ * in each mode.
966
+ * @num_modes: Number of Modes.
967
+ */
968
+ struct sdca_entity_ge {
969
+ struct snd_kcontrol_new * kctl ;
970
+ struct sdca_ge_mode * modes ;
971
+ int num_modes ;
972
+ };
973
+
907
974
/**
908
975
* struct sdca_entity - information for one SDCA Entity
909
976
* @label: String such as "OT 12".
910
977
* @id: Identifier used for addressing.
911
978
* @type: Type code for the Entity.
979
+ * @group: Pointer to Group Entity controlling this one, NULL if N/A.
912
980
* @sources: Dynamically allocated array pointing to each input Entity
913
981
* connected to this Entity.
914
982
* @controls: Dynamically allocated array of Controls.
@@ -917,12 +985,14 @@ enum sdca_entity_type {
917
985
* @iot: Input/Output Terminal specific Entity properties.
918
986
* @cs: Clock Source specific Entity properties.
919
987
* @pde: Power Domain Entity specific Entity properties.
988
+ * @ge: Group Entity specific Entity properties.
920
989
*/
921
990
struct sdca_entity {
922
991
const char * label ;
923
992
int id ;
924
993
enum sdca_entity_type type ;
925
994
995
+ struct sdca_entity * group ;
926
996
struct sdca_entity * * sources ;
927
997
struct sdca_control * controls ;
928
998
int num_sources ;
@@ -931,6 +1001,7 @@ struct sdca_entity {
931
1001
struct sdca_entity_iot iot ;
932
1002
struct sdca_entity_cs cs ;
933
1003
struct sdca_entity_pde pde ;
1004
+ struct sdca_entity_ge ge ;
934
1005
};
935
1006
};
936
1007
@@ -1113,6 +1184,25 @@ struct sdca_function_data {
1113
1184
unsigned int busy_max_delay ;
1114
1185
};
1115
1186
1187
+ static inline u32 sdca_range (struct sdca_control_range * range ,
1188
+ unsigned int col , unsigned int row )
1189
+ {
1190
+ return range -> data [(row * range -> cols ) + col ];
1191
+ }
1192
+
1193
+ static inline u32 sdca_range_search (struct sdca_control_range * range ,
1194
+ int search_col , int value , int result_col )
1195
+ {
1196
+ int i ;
1197
+
1198
+ for (i = 0 ; i < range -> rows ; i ++ ) {
1199
+ if (sdca_range (range , search_col , i ) == value )
1200
+ return sdca_range (range , result_col , i );
1201
+ }
1202
+
1203
+ return 0 ;
1204
+ }
1205
+
1116
1206
int sdca_parse_function (struct device * dev ,
1117
1207
struct sdca_function_desc * desc ,
1118
1208
struct sdca_function_data * function );
0 commit comments