@@ -89,6 +89,8 @@ static void usage(void)
printf("Usage: iecset [options] [cmd arg...]\n");
printf("Options:\n");
printf(" -D device specifies the control device to use\n");
+ printf(" for \"-Dhw:X,Y,Z\" Only control device X is mandatory\n");
+ printf(" the device(Y) and subdevice(Z) are optinal (default = 0)\n");
printf(" -c card specifies the card number to use (equiv. with -Dhw:#)\n");
printf(" -n number specifies the control index number (default = 0)\n");
printf(" -x dump the dump the AESx hex code for IEC958 PCM parameters\n");
@@ -99,6 +101,15 @@ static void usage(void)
}
}
+static int parse_device(char *parms, int *ctl_dev, int *dev, int *sdev)
+{
+
+ if (strncmp(parms, "hw", 2))
+ return 1;
+ sscanf(parms,"hw:%d,%d,%d",ctl_dev, dev, sdev);
+
+ return 0;
+}
/*
* parse iecset commands
@@ -312,6 +323,7 @@ int main(int argc, char **argv)
const char *dev = "default";
const char *spdif_str = SND_CTL_NAME_IEC958("", PLAYBACK, DEFAULT);
int spdif_index = -1;
+ int cdev, spdif_dev = -1, spdif_sdev = -1;
snd_ctl_t *ctl;
snd_ctl_elem_list_t *clist;
snd_ctl_elem_id_t *cid;
@@ -330,7 +342,11 @@ int main(int argc, char **argv)
while ((c = getopt(argc, argv, "D:c:n:xhi")) != -1) {
switch (c) {
case 'D':
- dev = optarg;
+ if (parse_device(optarg, &cdev, &spdif_dev, &spdif_sdev))
+ dev = optarg;
+ else
+ sprintf(tmpname, "hw:%d", cdev);
+ dev = tmpname;
break;
case 'c':
i = atoi(optarg);
@@ -376,15 +392,19 @@ int main(int argc, char **argv)
}
controls = snd_ctl_elem_list_get_used(clist);
- for (cidx = 0; cidx < controls; cidx++) {
- if (!strcmp(snd_ctl_elem_list_get_name(clist, cidx), spdif_str))
- if (spdif_index < 0 ||
- snd_ctl_elem_list_get_index(clist, cidx) == spdif_index)
+ for (cidx = 0; cidx < controls; cidx++)
+ if (!strcmp(snd_ctl_elem_list_get_name(clist, cidx), spdif_str)) {
+ if ((spdif_index < 0 ||
+ snd_ctl_elem_list_get_index(clist, cidx) == spdif_index) &&
+ (spdif_dev < 0 ||
+ snd_ctl_elem_list_get_device(clist, cidx) == spdif_dev) &&
+ (spdif_sdev < 0 ||
+ snd_ctl_elem_list_get_subdevice(clist, cidx) == spdif_sdev))
break;
}
if (cidx >= controls) {
- fprintf(stderr, "control \"%s\" (index %d) not found\n",
- spdif_str, spdif_index);
+ fprintf(stderr, "control \"%s\" (index %d, device %d, subdevice %d) not found\n",
+ spdif_str, spdif_index, spdif_dev, spdif_sdev);
return 1;
}
ASoc implementation force the index to 0. In case of multi devices that export the iec control, we need device and subdevice fields to differentiate and address the different controls. This patch extends "-D" option to be able to address control using PCM device/sub-device id. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com> --- iecset/iecset.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-)