您好!
我正在尝试限制 tlv320aic3110允许的最大音量。 在我们的初始测试中、当音量处于其最大默认音量时、它最终会损坏扬声器。 目前、我们正在使用 ALSA 控件降低默认音量、但我们希望有一个即使使用 ALSA 控件也无法超越的限值。 我的想法是使用从器件树中读取的一些值、这些值会写入相应的寄存器。
我已成功修改驱动程序以读取这些值并且正在写入一系列寄存器、但这似乎没有任何效果。 当我在我们的终端中加载操作系统并将音量级别修改为最大值时、我似乎在没有修改的情况下获得了相同的音量。
这些是我要写入的寄存器:
if (strncmp(name, "SP Analog Playback Volume", 25) == 0) { aic31xx->SP_Analog_Playback_Volume = 127 - limit; } if (strncmp(name, "SP Driver Playback Volume", 25) == 0) { aic31xx->SP_Driver_Playback_Volume = limit; } ret = snd_soc_component_write(component, AIC31XX_DACMIXERROUTE, 0x44); /* Page 1 / Register 35 (0x23): DAC_L and DAC_R Output Mixer Routing */ ret = snd_soc_component_write(component, AIC31XX_LANALOGHPL, 0xC0); /* Page 1 / Register 36 (0x24): Left Analog Volume to HPL */ ret = snd_soc_component_write(component, AIC31XX_RANALOGHPR, 0xC0); /* Page 1 / Register 37 (0x25): Right Analog Volume to HPR */ ret = snd_soc_component_write(component, AIC31XX_LANALOGSPL, (aic31xx->SP_Analog_Playback_Volume & 0x7F) | 0x80); /* Page 1 / Register 38 (0x26): Left Analog Volume to SPL */ ret = snd_soc_component_write(component, AIC31XX_RANALOGSPR, (aic31xx->SP_Analog_Playback_Volume & 0x7F) | 0x80); /* Page 1 / Register 39 (0x27): Right Analog Volume to SPR */ ret = snd_soc_component_write(component, AIC31XX_HPDRIVER, 0xc4); /* Page 1 / Register 31 (0x1F): Headphone Drivers */ ret = snd_soc_component_write(component, AIC31XX_HPLGAIN, 0x4d); /* Page 1 / Register 40 (0x28): HPL Driver */ ret = snd_soc_component_write(component, AIC31XX_HPRGAIN, 0x4d); /* Page 1 / Register 41 (0x29): HPR Driver */ ret = snd_soc_component_write(component, AIC31XX_SPLGAIN, ((aic31xx->SP_Driver_Playback_Volume & 0x03) << 3) | 0x5); /* Page 1 / Register 42 (0x2A): SPL Driver */ ret = snd_soc_component_write(component, AIC31XX_SPRGAIN, ((aic31xx->SP_Driver_Playback_Volume & 0x03) << 3) | 0x5); /* Page 1 / Register 43 (0x2B): SPR Driver */ ret = snd_soc_component_write(component, AIC31XX_SPKAMP, 0xc6); /* Page 1 / Register 32 (0x20): Class-D Speaker Amplifier */ ret = snd_soc_component_write(component, AIC31XX_LANALOGSPL, 0x74); /* Page 1 / Register 38 (0x26): Left Analog Volume to SPL */ ret = snd_soc_component_write(component, AIC31XX_RANALOGSPR, 0x74); /* Page 1 / Register 39 (0x27): Right Analog Volume to SPR */
我将在探针函数中的最后、即在读取前面提到的器件树中的值之后立即写入它们。 根据写入函数返回的值、该操作成功、读取函数返回与我尝试写入的值相同的值。
我是应该在不同的地方写入这些寄存器还是以特定的频率(例如每分钟)写入这些寄存器? 这可能是完全不同的事情吗?
要修改音量一旦我的更改被安装,我要使用 alsamixer,我要使用 speaker-test 来产生声音。