|
|
@ -1,4 +1,3 @@ |
|
|
|
#!/usr/bin/env python |
|
|
|
|
|
|
|
from smbus2 import SMBus |
|
|
|
from smbus2 import SMBus |
|
|
|
from collections import namedtuple |
|
|
|
from collections import namedtuple |
|
|
|
|
|
|
|
|
|
|
@ -63,11 +62,43 @@ BASE_CONFIG = [ |
|
|
|
AmpConfig("Zero-crossing detection disabled", 0b0, 0x49, 5, 0b00100000), |
|
|
|
AmpConfig("Zero-crossing detection disabled", 0b0, 0x49, 5, 0b00100000), |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
BASE_CONFIG += configs_from_eq_params(0x84, EQParams(0x274F, 0xC0FF, 0x3BF9, 0x0B3C, 0x1656)) |
|
|
|
CONFIGS = { |
|
|
|
BASE_CONFIG += configs_from_eq_params(0x8E, EQParams(0x1009, 0xC6BF, 0x2952, 0x1C97, 0x30DF)) |
|
|
|
"tici": [ |
|
|
|
BASE_CONFIG += configs_from_eq_params(0x98, EQParams(0x0F75, 0xCBE5, 0x0ED2, 0x2528, 0x3E42)) |
|
|
|
*configs_from_eq_params(0x84, EQParams(0x274F, 0xC0FF, 0x3BF9, 0x0B3C, 0x1656)), |
|
|
|
BASE_CONFIG += configs_from_eq_params(0xA2, EQParams(0x091F, 0x3D4C, 0xCE11, 0x1266, 0x2807)) |
|
|
|
*configs_from_eq_params(0x8E, EQParams(0x1009, 0xC6BF, 0x2952, 0x1C97, 0x30DF)), |
|
|
|
BASE_CONFIG += configs_from_eq_params(0xAC, EQParams(0x0A9E, 0x3F20, 0xE573, 0x0A8B, 0x3A3B)) |
|
|
|
*configs_from_eq_params(0x98, EQParams(0x0F75, 0xCBE5, 0x0ED2, 0x2528, 0x3E42)), |
|
|
|
|
|
|
|
*configs_from_eq_params(0xA2, EQParams(0x091F, 0x3D4C, 0xCE11, 0x1266, 0x2807)), |
|
|
|
|
|
|
|
*configs_from_eq_params(0xAC, EQParams(0x0A9E, 0x3F20, 0xE573, 0x0A8B, 0x3A3B)), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
"tizi": [ |
|
|
|
|
|
|
|
AmpConfig("Left speaker output from left DAC", 0b1, 0x2B, 0, 0b11111111), |
|
|
|
|
|
|
|
AmpConfig("Left Speaker Mixer Gain", 0b00, 0x2D, 0, 0b00000011), |
|
|
|
|
|
|
|
AmpConfig("Left speaker output volume", 0x1F, 0x3D, 0, 0b00011111), |
|
|
|
|
|
|
|
AmpConfig("Right speaker output volume", 0x1F, 0x3E, 0, 0b00011111), |
|
|
|
|
|
|
|
AmpConfig("DAI1 attenuation (DV1)", 0x4, 0x2F, 0, 0b00001111), |
|
|
|
|
|
|
|
AmpConfig("DAI2 attenuation (DV2)", 0x4, 0x31, 0, 0b00001111), |
|
|
|
|
|
|
|
AmpConfig("DAI2: DC blocking", 0b0, 0x20, 0, 0b00000001), |
|
|
|
|
|
|
|
AmpConfig("ALC enable", 0b0, 0x43, 7, 0b10000000), |
|
|
|
|
|
|
|
AmpConfig("DAI2 EQ attenuation", 0x2, 0x32, 0, 0b00001111), |
|
|
|
|
|
|
|
AmpConfig("Excursion limiter upper corner freq", 0b001, 0x41, 4, 0b01110000), |
|
|
|
|
|
|
|
AmpConfig("Excursion limiter threshold", 0b100, 0x42, 0, 0b00001111), |
|
|
|
|
|
|
|
AmpConfig("Distortion limit (THDCLP)", 0x0, 0x46, 4, 0b11110000), |
|
|
|
|
|
|
|
AmpConfig("Distortion limiter release time constant", 0b1, 0x46, 0, 0b00000001), |
|
|
|
|
|
|
|
AmpConfig("Left DAC input mixer: DAI1 left", 0b0, 0x22, 7, 0b10000000), |
|
|
|
|
|
|
|
AmpConfig("Left DAC input mixer: DAI1 right", 0b0, 0x22, 6, 0b01000000), |
|
|
|
|
|
|
|
AmpConfig("Left DAC input mixer: DAI2 left", 0b1, 0x22, 5, 0b00100000), |
|
|
|
|
|
|
|
AmpConfig("Left DAC input mixer: DAI2 right", 0b0, 0x22, 4, 0b00010000), |
|
|
|
|
|
|
|
AmpConfig("Right DAC input mixer: DAI2 left", 0b0, 0x22, 1, 0b00000010), |
|
|
|
|
|
|
|
AmpConfig("Right DAC input mixer: DAI2 right", 0b1, 0x22, 0, 0b00000001), |
|
|
|
|
|
|
|
AmpConfig("Volume adjustment smoothing disabled", 0b1, 0x49, 6, 0b01000000), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*configs_from_eq_params(0x84, EQParams(0x3084, 0xC023, 0x3D60, 0x042B, 0x1222)), |
|
|
|
|
|
|
|
*configs_from_eq_params(0x8E, EQParams(0x2FB2, 0xC05C, 0x3BD3, 0x06C5, 0x16BB)), |
|
|
|
|
|
|
|
*configs_from_eq_params(0x98, EQParams(0x21F5, 0xDF73, 0x2DFE, 0x371A, 0x2C80)), |
|
|
|
|
|
|
|
*configs_from_eq_params(0xA2, EQParams(0x2A5A, 0x0AD0, 0x14FA, 0x3F14, 0x3C76)), |
|
|
|
|
|
|
|
*configs_from_eq_params(0xAC, EQParams(0x1577, 0x3FAE, 0xEE60, 0x0664, 0x3D86)), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class Amplifier: |
|
|
|
class Amplifier: |
|
|
|
AMP_I2C_BUS = 0 |
|
|
|
AMP_I2C_BUS = 0 |
|
|
@ -91,14 +122,13 @@ class Amplifier: |
|
|
|
def set_global_shutdown(self, amp_disabled): |
|
|
|
def set_global_shutdown(self, amp_disabled): |
|
|
|
self.set_config(AmpConfig("Global shutdown", 0b0 if amp_disabled else 0b1, 0x51, 7, 0b10000000)) |
|
|
|
self.set_config(AmpConfig("Global shutdown", 0b0 if amp_disabled else 0b1, 0x51, 7, 0b10000000)) |
|
|
|
|
|
|
|
|
|
|
|
def initialize_configuration(self): |
|
|
|
def initialize_configuration(self, model): |
|
|
|
self.set_global_shutdown(amp_disabled=True) |
|
|
|
self.set_global_shutdown(amp_disabled=True) |
|
|
|
|
|
|
|
|
|
|
|
for config in BASE_CONFIG: |
|
|
|
for config in BASE_CONFIG: |
|
|
|
self.set_config(config) |
|
|
|
self.set_config(config) |
|
|
|
|
|
|
|
|
|
|
|
self.set_global_shutdown(amp_disabled=False) |
|
|
|
for config in CONFIGS[model]: |
|
|
|
|
|
|
|
self.set_config(config) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
self.set_global_shutdown(amp_disabled=False) |
|
|
|
Amplifier(debug=True).initialize_configuration() |
|
|
|
|
|
|
|