Hi,
You should approach the same court which detained your passport and move an application to hand over the passport as it is due for renewal for visa , court will allow this with certain conditions as it feel fit .
you can seek permission of the court to travel abroad showing the necessity and urgency, court will decide on the application considering the seriousness of your case and your past conduct.
By the way what is the charges made against you in the F.I.R, What are the sections.