[audio][aml-g12-tdm] Add extra metadata consistency checks

Make sure that the number of channels enabled in lanes
matches the number of channels in the ring buffer, most
likely this is a configuration error if not true.
Also only default bits per sample and slot for I2S and
StereoLeftJustified DAI types, making it mandatory for
TDM cases to explicitly specify these sizes.

Test: device-enumeration-test on Nelson

Change-Id: I7f15f46d4463d1627805e7f7a29d9ec9d8468480
diff --git a/src/media/audio/drivers/aml-g12-tdm/aml-tdm-config-device.cc b/src/media/audio/drivers/aml-g12-tdm/aml-tdm-config-device.cc
index ea0f817..f287ae2 100644
--- a/src/media/audio/drivers/aml-g12-tdm/aml-tdm-config-device.cc
+++ b/src/media/audio/drivers/aml-g12-tdm/aml-tdm-config-device.cc
@@ -115,6 +115,10 @@
     }
     lane_start = channel;
   }
+  // Number of channels enabled in lanes must match the number of channels in the ring buffer.
+  // If some weird configuration requires this constrain to not be true, remove this check.
+  // Most configurations would be an error if these did not match
+  ZX_ASSERT(channel == metadata.ring_buffer.number_of_channels);
 
   device_->ConfigTdmSlot(bitoffset, static_cast<uint8_t>(metadata.dai.number_of_channels - 1),
                          metadata.dai.bits_per_slot - 1, metadata.dai.bits_per_sample - 1,
@@ -217,12 +221,12 @@
   if (metadata.dai.type == metadata::DaiType::I2s ||
       metadata.dai.type == metadata::DaiType::StereoLeftJustified) {
     metadata.dai.number_of_channels = 2;
-  }
-  if (metadata.dai.bits_per_sample == 0) {
-    metadata.dai.bits_per_sample = 16;
-  }
-  if (metadata.dai.bits_per_slot == 0) {
-    metadata.dai.bits_per_slot = 32;
+    if (metadata.dai.bits_per_sample == 0) {
+      metadata.dai.bits_per_sample = 16;
+    }
+    if (metadata.dai.bits_per_slot == 0) {
+      metadata.dai.bits_per_slot = 32;
+    }
   }
   if (metadata.dai.bits_per_slot != 32 && metadata.dai.bits_per_slot != 16) {
     zxlogf(ERROR, "metadata unsupported bits per slot %d", metadata.dai.bits_per_slot);