There’s a hilarious explanation behind Brian McKnight’s new x-rated song — the singer tells TMZ Live, he’s been holed up in his house going stir crazy with a bum ankle … and the dirty ditty came to him in a moment of sheer boredom.

Brian called in moments ago and said, “I’ve been home for a month … I’ve got this boot on my foot. I’m like a month away from Achilles tendon surgery, so I’ve been stuck in the house.”

Brian added, the song “isn’t for everyone. It’s a parody. I’m having fun. Because basically I have nothing else else to do.”

In case you haven’t heard it … Brian released a clip of a new song on YouTube called “If You’re Ready to Learn” — featuring the lyrics, “Let me show you how your p—y works/Since you didn’t bring it to me first.