From 76b09f1197b9de87a088b00b97db957b1e9bca29 Mon Sep 17 00:00:00 2001 From: Baili Deng Date: Mon, 21 Oct 2024 14:11:21 +0800 Subject: [PATCH] sound_card_init: Remove workaround for applying TAS2563 Calibration Data The data length portion for TAS2563 Calibration Data is now not automatically changed. Remove the workaround where we add a buffer byte and just apply the data length byte to the calibration data instead. BUG=b:345629513 TEST=`amixer -c 0 contents` and check that the Speaker Calibrated Data is applied correctly Change-Id: I5618d03d739d4903bb01ea7355422c8f43f7ca4f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5939020 Auto-Submit: Baili Deng Tested-by: Baili Deng Reviewed-by: Judy Hsiao Tested-by: chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com Commit-Queue: Baili Deng --- sound_card_init/amp/src/tas2563/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sound_card_init/amp/src/tas2563/mod.rs b/sound_card_init/amp/src/tas2563/mod.rs index 9af64b1cf..2cbd8236a 100644 --- a/sound_card_init/amp/src/tas2563/mod.rs +++ b/sound_card_init/amp/src/tas2563/mod.rs @@ -282,6 +282,9 @@ impl Amp for TAS2563 { impl TAS2563 { const TEMP_UPPER_LIMIT_CELSIUS: f32 = 40.0; const TEMP_LOWER_LIMIT_CELSIUS: f32 = 0.0; + const CALIB_DATA_LEN_2_CH: usize = 59; + const CALIB_DATA_LEN_4_CH: usize = 101; + /// Creates an `TAS2563`. /// # Arguments /// @@ -308,6 +311,13 @@ impl TAS2563 { /// Applies the calibration value to the amp. fn apply_calibration_value(&mut self, calib: &[TAS2563CalibData]) -> Result<()> { let mut values: Vec = Vec::new(); + if calib.len() == 2 { + values.push(Self::CALIB_DATA_LEN_2_CH as u8); + } else if calib.len() == 4 { + values.push(Self::CALIB_DATA_LEN_4_CH as u8); + } else { + return Err(Error::InvalidChannelNumber(calib.len().try_into().unwrap()).into()); + } for ( ch, &TAS2563CalibData { @@ -330,8 +340,6 @@ impl TAS2563 { values.extend(rms_pow.to_be_bytes()); values.extend(tlimit.to_be_bytes()); } - // Add the extra byte for fitting the total length of the data. - values.push(0 as u8); if calib.len() == 2 { self.card