Skip to content

Commit 1f69b91

Browse files
mjchen0cfriedt
authored andcommitted
drivers: audio: dmic_mcux: remove arbitrary mapping of pdm to dmic channel
The dmic_mcux driver required a mapping of paired dmics to specify the same pdm number, and would arbitrarily assign the left channel of the pair to even dmic channel number and the right to an odd dmic channel number. Change this so that the pdm number in the mapping is used as the dmic channel number, and paired dmics are checked to specify consecutive pdm numbers (instead of the same pdm number). This allows users to control explicitly which dmic channel to use and whether that dmic channel is left or right, without this arbitrary indirect mapping. This is important in case they want a dmic that is wired to be right channel to be assigned to dmic channel 0, which is the only channel that supports hwvad. Signed-off-by: Mike J. Chen <mjchen@google.com>
1 parent 07efbe6 commit 1f69b91

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

drivers/audio/dmic_mcux.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,11 @@ static uint8_t dmic_mcux_hw_chan(struct mcux_dmic_drv_data *drv_data,
6767
enum pdm_lr lr;
6868
uint8_t hw_chan;
6969

70-
/* This function assigns hardware channel "n" to the left channel,
71-
* and hardware channel "n+1" to the right channel. This choice is
72-
* arbitrary, but must be followed throughout the driver.
73-
*/
7470
dmic_parse_channel_map(drv_data->chan_map_lo,
7571
drv_data->chan_map_hi,
7672
log_chan, &hw_chan, &lr);
77-
if (lr == PDM_CHAN_LEFT) {
78-
return hw_chan * 2;
79-
} else {
80-
return (hw_chan * 2) + 1;
81-
}
73+
74+
return hw_chan;
8275
}
8376

8477
static void dmic_mcux_activate_channels(struct mcux_dmic_drv_data *drv_data,
@@ -501,9 +494,9 @@ static int dmic_mcux_configure(const struct device *dev,
501494
dmic_parse_channel_map(channel->req_chan_map_lo,
502495
channel->req_chan_map_hi,
503496
chan + 1, &hw_chan_1, &lr_1);
504-
/* Verify that paired channels use same hardware index */
497+
/* Verify that paired channels use consecutive hardware index */
505498
if ((lr_0 == lr_1) ||
506-
(hw_chan_0 != hw_chan_1)) {
499+
(hw_chan_1 != (hw_chan_0 + 1))) {
507500
return -EINVAL;
508501
}
509502
}

0 commit comments

Comments
 (0)