with his clothes torn and with dirt on his head
Tearing one's clothes and putting dirt on one's head is an act of mourning humbling oneself.
he lay facedown on the ground and prostrated himself
This was an act of this man humbling himself before David who was now the king of Israel.