I did go through hdajackretask and alsa project to retask my headphone to microphone.

But what I am wondering if its possible to continuously alternate between microphone and head-phone using script?

Say for few seconds the jack records and then it switches back to speaker and then starts recording again and loop goes on..


Have a look at Documentation/sound/hd-audio/notes.rst in the Linux kernel source. You can write to user_pin_configs and reconfig to trigger reconfiguration, but the driver will reset, so I'm not sure if it's a good way to do that...

Alternatively, you could try to configure the codec to playback and record on the same pin at the same time (if this is what you want). But this may need tricking the ALSA driver into thinking that it's really doing playback and recording to/from different pins, and then changing the codec configuration with hda-verb without the driver noticing. Not easy, but worth a try.

I'm not sure what you are going to try to do (use the headphone speakers as microphone?), and I don't think I want to test that on my hardware. :-)

  • Yes I want to use headphone as speaker alternatively. I dont want to record and play at same time rather do it alternatively. – Jay Jan 5 '18 at 14:40
  • Nothing stops you from muting playback and only recording while playback is muted, and then unmuting and stop recording ... might be easier to do than go through the hassle of switching and reinitializing the driver. – dirkt Jan 5 '18 at 15:38
  • How can record and play from same port without doing jack retasking each time? – Jay Jan 6 '18 at 10:32
  • As I said: Start record and playback, see if you can use hda_verb to change the codec mux/amp/switch to the same pin widget. Look at cat /proc/asound/card*/codec\#* for your codec configuration, maybe compare what it does when you use hdajacketask. Read up in the HDA Standard (google) what the verbs do. I'm not going to try this on my hardware, so I can't give you step-by-step instructions (which depend on your codec, anyway). – dirkt Jan 6 '18 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.