Skip to content

Commit aaf08d7

Browse files
committed
Some minor SDCA preparation
Merge series from Charles Keepax <[email protected]>: Make some small fixups and add some minor missing features that will be needed for the next major part of the SDCA work. This series doesn't do a lot on its own, but as the next series will add all the ALSA control and DAPM graph creation it's probably best to get these minor things out of the way to simplify review on the bigger stuff.
2 parents 65086ec + d1cd13f commit aaf08d7

File tree

2 files changed

+422
-42
lines changed

2 files changed

+422
-42
lines changed

include/sound/sdca_function.h

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ struct sdca_function_desc;
4444
*/
4545
#define SDCA_MAX_DELAY_COUNT 256
4646

47+
/*
48+
* Sanity check on size of affected controls data, can be expanded if needed.
49+
*/
50+
#define SDCA_MAX_AFFECTED_COUNT 2048
51+
4752
/**
4853
* enum sdca_function_type - SDCA Function Type codes
4954
* @SDCA_FUNCTION_TYPE_SMART_AMP: Amplifier with protection features.
@@ -600,6 +605,27 @@ enum sdca_entity0_controls {
600605
#define SDCA_CTL_DEVICE_VERSION_NAME "Device Version"
601606
#define SDCA_CTL_DEVICE_SDCA_VERSION_NAME "Device SDCA Version"
602607

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+
603629
/**
604630
* enum sdca_access_mode - SDCA Control access mode
605631
*
@@ -653,6 +679,7 @@ struct sdca_control_range {
653679
* @cn_list: A bitmask showing the valid Control Numbers within this Control,
654680
* Control Numbers typically represent channels.
655681
* @range: Buffer describing valid range of values for the Control.
682+
* @type: Format of the data in the Control.
656683
* @mode: Access mode of the Control.
657684
* @layers: Bitmask of access layers of the Control.
658685
* @deferrable: Indicates if the access to the Control can be deferred.
@@ -669,6 +696,7 @@ struct sdca_control {
669696
u64 cn_list;
670697

671698
struct sdca_control_range range;
699+
enum sdca_control_datatype type;
672700
enum sdca_access_mode mode;
673701
u8 layers;
674702

@@ -904,11 +932,51 @@ enum sdca_entity_type {
904932
SDCA_ENTITY_TYPE_HIDE = 0x31,
905933
};
906934

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+
907974
/**
908975
* struct sdca_entity - information for one SDCA Entity
909976
* @label: String such as "OT 12".
910977
* @id: Identifier used for addressing.
911978
* @type: Type code for the Entity.
979+
* @group: Pointer to Group Entity controlling this one, NULL if N/A.
912980
* @sources: Dynamically allocated array pointing to each input Entity
913981
* connected to this Entity.
914982
* @controls: Dynamically allocated array of Controls.
@@ -917,12 +985,14 @@ enum sdca_entity_type {
917985
* @iot: Input/Output Terminal specific Entity properties.
918986
* @cs: Clock Source specific Entity properties.
919987
* @pde: Power Domain Entity specific Entity properties.
988+
* @ge: Group Entity specific Entity properties.
920989
*/
921990
struct sdca_entity {
922991
const char *label;
923992
int id;
924993
enum sdca_entity_type type;
925994

995+
struct sdca_entity *group;
926996
struct sdca_entity **sources;
927997
struct sdca_control *controls;
928998
int num_sources;
@@ -931,6 +1001,7 @@ struct sdca_entity {
9311001
struct sdca_entity_iot iot;
9321002
struct sdca_entity_cs cs;
9331003
struct sdca_entity_pde pde;
1004+
struct sdca_entity_ge ge;
9341005
};
9351006
};
9361007

@@ -1113,6 +1184,25 @@ struct sdca_function_data {
11131184
unsigned int busy_max_delay;
11141185
};
11151186

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+
11161206
int sdca_parse_function(struct device *dev,
11171207
struct sdca_function_desc *desc,
11181208
struct sdca_function_data *function);

0 commit comments

Comments
 (0)