I've monitored the state if /dev/input/jack, recorded some sequences that are generated when I plug in/out mic jack and then figured out how simulate these sequences using <linux/input.h>