App note on Cirrus Logic’s WM9712 jack plug auto-detection by monitoring the connected headphone resistance. Link here (PDF)
This application note describes two operations associated with using headset. The first is the facility to automatically switch between a mono ear speaker and stereo headphones for use in a Smartphone, PDA etc. The second operation is a method which can be used to detect if stereo headphones have been attached or if a mono headset with microphone has been attached.