I also had the same problem recently with my Lenovo Legion Y540-15IRH, even though in my case I am running Ubuntu 20.04. I tried several suggestions from the first link you provided but nothing worked.
However following the advice given in this this answer I managed to get the microphone to be detected:
- Run
hdajackretask
- Switch the tab on top to the appropriate sound codec, in my case it was
Realtek ALC257
- Tick override in the "Black Mic, right side" section and chose "Microphone" in the dropdown selection
- "Install boot override" and reboot
At this point, the microphone could be detected in Ubuntu, but I had no sound in the headset so then I did the following steps:
- Go back to
hdajackretask
on the same codec as before.
- Tick override in the "Black Headphone, right side" section and chose "Microphone" in the dropdown selection
- "Install boot override" and reboot
- Using
alsamixer
make sure all the "headphone" device is at least above zero. If not increase its volume with the arrow keys.
If this doesn't work I suggest trying other options in the dropdown selector in the "Black Mic, Right side" section in hdajackretask
and then "Install boot override" and reboot at every attempt.