Skip to content

Commit e8cb348

Browse files
committed
configmgr: Add get_device_alsadev() to get a device's card/device number
Now that specifying card and device numbers for a device is possible, add a function to get them. Change-Id: I78c42a86b09e9ecd93232fa7d0acd0b4dc8b7d22 Signed-off-by: Vincent Knecht <vincent.knecht@mailoo.org>
1 parent 0d506e6 commit e8cb348

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

configmgr/audio_config.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,31 @@ int get_stream_constant_int32(const struct hw_stream *stream,
10801080
return ret;
10811081
}
10821082

1083+
/*********************************************************************
1084+
* Device
1085+
*********************************************************************/
1086+
1087+
int get_device_alsadev(struct config_mgr *cm, uint32_t type, uint32_t *cardnum, uint32_t *devnum)
1088+
{
1089+
struct device *pdev = cm->device_array.devices;
1090+
int dev_count = cm->device_array.count;
1091+
1092+
while (dev_count > 0) {
1093+
if (pdev->type == type) {
1094+
cardnum = &pdev->card_number;
1095+
devnum = &pdev->device_number;
1096+
if (*cardnum < UINT_MAX && *devnum < UINT_MAX) {
1097+
return 0;
1098+
}
1099+
return -ENODEV;
1100+
}
1101+
--dev_count;
1102+
++pdev;
1103+
}
1104+
1105+
return -ENOENT;
1106+
}
1107+
10831108
/*********************************************************************
10841109
* Config file parsing
10851110
*

include/tinyhal/audio_config.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct mixer;
3232
struct mixer_ctl;
3333
struct config_mgr;
3434
struct audio_config;
35+
struct device;
3536

3637
/** Stream type */
3738
enum stream_type {
@@ -187,6 +188,13 @@ int apply_use_case( const struct hw_stream* stream,
187188
const char *setting,
188189
const char *case_name);
189190

191+
/** Get the ALSA card and device number associated to this device
192+
* @return 0 if the device type has card and device numbers defined
193+
* @return -ENODEV if the device type has no card and device number defined
194+
* @return -ENOENT if the device type was not found
195+
*/
196+
int get_device_alsadev(struct config_mgr *cm, uint32_t type, uint32_t *cardnum, uint32_t *devnum);
197+
190198
#if defined(__cplusplus)
191199
} /* extern "C" */
192200
#endif

0 commit comments

Comments
 (0)