Re: [PATCH 12/18] ASoC: codecs: mt6357: add MT6357 codec

Alexandre Mergnat
2024-03-15T15:05:36Z

On 15/03/2024 15:30, Mark Brown wrote:
> On Fri, Mar 15, 2024 at 12:01:12PM +0100, Alexandre Mergnat wrote:
>> On 13/03/2024 18:23, Mark Brown wrote:
>>> On Tue, Mar 12, 2024 at 07:03:25PM +0100, Alexandre Mergnat wrote:
>
>>>> Actually you must save the values because the gain selected by the user will
>>>> be override to do a ramp => volume_ramp(.....):
>>>> - When you switch on the HP, you start from gain=-40db to final_gain
>>>> (selected by user).
>>>> - When you switch off the HP, you start from final_gain (selected by user)
>>>> to gain=-40db.
>
>>> You can just read the value back when you need to do a ramp?
>
>> You can't. Because you will read -40db when HP isn't playing sound. That is
>> why the gain is saved into the struct.
>
>> Let me know, when you change de gain to do a ramp down (start from user gain
>> to gain=-40db), next time for the ramp up, how/where do you find the user
>> gain ?
>
> In the register. You only need to reset the gain to -40dB at the start
> of the ramp.

Sorry but I don't understand your logic, I'm not able to implement it...
If I'm at -10dB and doing a ramp to reach -40dB, next time I will read
the register the value will be -40dB.

This implementation is also done in other MTK audio codec drivers.

>
>>>> Also, the microphone's gain change when it's enabled/disabled.
>
>>> I don't understand what this means?
>
>> When microphone isn't capturing, the gain read back from the register is
>> 0dB. I've put some logs in my code and do capture to show how it works:
>
> Is this a property of the hardware or a property of your driver?

At the end of the capture, the gain is set to 0dB by the driver.
At the start of the capture, the gain is set to the setup gain.

AFAII from the comment in the code, it's done to avoid the "pop noises".

>
>>>>>> + /* ul channel swap */
>>>>>> + SOC_SINGLE("UL LR Swap", MT6357_AFE_UL_DL_CON0, AFE_UL_LR_SWAP_SFT, 1, 0),
>
>>>>> On/off controls should end in Switch.
>
>>>> Sorry, I don't understand your comment. Can you reword it please ?
>
>>> See control-names.rst. Run mixer-test on a card with this driver and
>>> fix all the issues it reports.
>
>> Ok the name is the issue for you AFAII.
>> This control isn't for on/off but swap Left and Right.
>> From the codec documentation:
>> "Swaps audio UL L/R channel before UL SRC"
>> This control is overkill, I will remove it
>
> This is turning the swapping on and off.

--
Regards,
Alexandre