@@ -271,6 +271,7 @@ static int sun4i_i2s_read_channel_slots(struct device *dev, struct sun4i_i2s *i2
{
struct device_node *np = dev->of_node;
int max_channels = ARRAY_SIZE(i2s->channel_dins);
+ int slot_max;
int ret;
/* Use a 1:1 mapping by default */
@@ -290,6 +291,16 @@ static int sun4i_i2s_read_channel_slots(struct device *dev, struct sun4i_i2s *i2
if (ret < 0)
return ret;
+ for (int i = 0; i < ret; ++i) {
+ int slot = i2s->channel_slots[i];
+
+ if (slot_max < slot)
+ slot_max = slot;
+ }
+
+ /* Add 1 to be inclusive of slot 0 */
+ i2s->slots = slot_max + 1;
+
return 0;
}
The current controller code assumes a 1:1 relationship between audio channel and TDM slot. This may not be the case when slots are set explicitly. Instead figure out how many slots we need based on the number of slots used in the channel map. This allows the case of reading multiple data pins on a single slot. Signed-off-by: John Watts <contact@jookia.org> --- sound/soc/sunxi/sun4i-i2s.c | 11 +++++++++++ 1 file changed, 11 insertions(+)