Skip to content

Commit

Permalink
sound_card_init: apply calibration results for TAS2563
Browse files Browse the repository at this point in the history
Implement the flow to apply the TAS2563 amp calibration parameters.
The calibration parameters are read from VPD and feed by mixer controls
every boot time.

BUG=b:346949244
TEST=ciri.TAS2563.yaml contents
```
amp_calibrations:
  controls:
    -
      cal_data: "Speaker Calibrated Data"
    -
      cal_data: "Speaker Calibrated Data"
  rdc_ranges:
    -
        lower: 6.525
        upper: 7.975
    -
        lower: 6.525
        upper: 7.975
```
TEST=
```
"dsm_calib_value_0"="003a2457072da72f08119cb074004bef2f2bc00000"
"dsm_calib_value_1"="013a093bf12d91e67611a4ea3e004bdd7a2bc00000"
```
TEST=`/usr/bin/sound_card_init boot_time_calibration --amp TAS2563 --id
sofmt8188tas256 --conf ciri.TAS2563.yaml` and check `amixer -c 0
contents` for changed `Speaker Calibrated Data`

Disallow-Recycled-Builds: test-failures
Change-Id: Ia51f358f4eef57a609520e8b2d459e637b84f6c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5628928
Reviewed-by: Judy Hsiao <[email protected]>
Tested-by: [email protected] <[email protected]>
Tested-by: Baili Deng <[email protected]>
Commit-Queue: Baili Deng <[email protected]>
  • Loading branch information
baili0411 authored and Chromeos LUCI committed Aug 9, 2024
1 parent 5117413 commit 075bf6e
Show file tree
Hide file tree
Showing 8 changed files with 493 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sound_card_init/amp/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use thiserror::Error as ThisError;
use crate::cs35l41;
use crate::max98373d;
use crate::max98390d;
use crate::tas2563;

pub type Result<T> = std::result::Result<T, Error>;

Expand All @@ -34,6 +35,8 @@ pub enum Error {
SerdeJsonError(#[from] serde_json::Error),
#[error(transparent)]
SerdeYamlError(#[from] serde_yaml::Error),
#[error(transparent)]
Tas2563Error(#[from] tas2563::Error),
#[error("unsupported amp: {0}")]
UnsupportedAmp(String),
}
Expand All @@ -50,6 +53,7 @@ impl From<&Error> for UMASoundCardInitResult {
Error::Max98390Error(_) => UMASoundCardInitResult::Max98390Error,
Error::SerdeJsonError(_) => UMASoundCardInitResult::SerdeJsonError,
Error::SerdeYamlError(_) => UMASoundCardInitResult::SerdeYamlError,
Error::Tas2563Error(_) => UMASoundCardInitResult::Tas2563Error,
Error::UnsupportedAmp(_) => UMASoundCardInitResult::UnsupportedAmp,
}
}
Expand Down
5 changes: 5 additions & 0 deletions sound_card_init/amp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod cs35l41;
mod error;
mod max98373d;
mod max98390d;
mod tas2563;
use std::path::PathBuf;

use alc1011::ALC1011;
Expand All @@ -20,6 +21,7 @@ use log::info;
use max98373d::Max98373;
use max98390d::Max98390;
use serde::Serialize;
use tas2563::TAS2563;

pub use crate::error::Error;
pub use crate::error::Result;
Expand Down Expand Up @@ -64,6 +66,9 @@ impl<'a> AmpBuilder<'a> {
"MAX98390" => {
Ok(Box::new(Max98390::new(self.sound_card_id, &self.config_path)?) as Box<dyn Amp>)
}
"TAS2563" => {
Ok(Box::new(TAS2563::new(self.sound_card_id, &self.config_path)?) as Box<dyn Amp>)
}
_ => Err(Error::UnsupportedAmp(self.amp.to_owned())),
}
}
Expand Down
21 changes: 21 additions & 0 deletions sound_card_init/amp/src/tas2563/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2024 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use std::path::PathBuf;

use remain::sorted;
use thiserror::Error as ThisError;

#[sorted]
#[derive(Debug, ThisError)]
pub enum Error {
#[error("failed to apply calibration results. status: {0}")]
ApplyCalibrationFailed(i32),
#[error("invalid CalibApplyStatus: {0}")]
InvalidCalibApplyStatus(i32),
#[error("invalid Channel Number: {0}")]
InvalidChannelNumber(i32),
#[error("invalid VPD Byte Count {0}")]
InvalidVPDByteCount(i32),
}
Loading

0 comments on commit 075bf6e

Please sign in to comment.