Headphones not detected when plugged before boot

this works for me on 18.04, I had several problems and now all solved, try these steps I hope it help.

Step One (headset instead of headphone)

if you have a headset with one jack for both Mic and headphone and it's not working you need to do these :

check if your last three lines in /etc/modprobe.d/alsa-base.conf are similar to:

options snd-usb-audio index=-2
options snd-hda-intel position_fix=1
options snd-hda-intel model=,dell-headset-multi

You probably don't have the last two lines. Add them at the end of the file and save it. with these settings whenever you plugged your headphone into your PC/laptop ubuntu asks you if it's a headset a Mic or a headphone.

Step Two (echo cancellation)

for disabling echo cancellation and some noise open this file :

/etc/pulse/default.pa

and add

load-module module-echo-cancel

some where into it.

and finally Step Three (your answer)

With this method you can restart your audio card module so your headphone can work again without restarting your PC/Laptop :

sudo modprobe snd-hda-intel

it should work :) for doing this at startup do this :

sudo sh -c 'echo "snd-hda-intel" >> /etc/modules'

and even if this method didn't work too :/ you need to disable the secure boot as mentioned here.