The idiom funny farm is a euphemism for a psychiatric clinic. These places are also called mental hospitals, mental institutions, insane asylums, psych wards, the crazy house, the loony bin, and so on. The idiom is normally used in a joking way, but is sometimes meant seriously, depending on the context.