As an R&B and boogie-woogie piano player, Daryl Davis has had some wild times. He’s shared the stage with Chuck Berry, Little Richard and Jerry Lee Lewis, and back in the day he used to play a “hot piano” that was literally on fire.

But few days were as surreal as the one during which a Ku Klux Klan member called the black musician for advice after being promoted to a higher rank within the hate group.

“He called me to ask what being a Great Titan meant,” Davis says. “He didn’t do his homework. The [induction] ceremony was pending, and he was too embarrassed to ask the Grand Dragon. So he called me.”

The 58-year-old Davis has been befriending Klan members for decades now. If they leave the group — as he says 20-odd men have over the years, thanks to him — they give him their Klan robes and regalia, for which Davis plans to eventually create a museum. His bookshelves house an extensive collection of KKK literature, and he claims to know more about the group’s history than many of its members.

“That’s my weapon,” Davis says. “The most powerful tools you can have are information and knowledge. I know how these groups operate. I know how they think.”

Davis’ philosophy is simple: “Allow them to air their views,” he says, “and there is an excellent chance that they will reciprocate.”

The most powerful tools you can have are information and knowledge. I know how these groups operate. I know how they think.

His quest to convert Klan members, handshake by handshake, is the subject of the documentary “Accidental Courtesy,” now playing, which follows the gregarious Davis as he visits rallies and chats with members in diners, bars, conference rooms and even his own home.

He has formed long-standing friendships with some — one attended Davis’ wedding to a white woman, even though he opposes interracial marriage.

“Because it’s Daryl,” says the man.

It’s a head-scratcher for many, but the musician maintains it’s the most logical way to break through belief systems predicated on seeing minorities as less than human.

Raised by parents who worked in the foreign service in the 1960s and enrolled their son in diverse international schools, Davis says he’s “seen the future,” and it’s one where race ceases to matter. Engaging with racists on common ground, he says, is the best way to show them how backward their beliefs are.

One of his favorite topics? Music.

“Everybody likes music,” says Davis, a Maryland resident.

“And rock ’n’ roll — that was the music that brought white youth and black youth together for the first time in American music history. Venues had segregated seating — but when Chuck Berry fused together blues, boogie-woogie and country music, it caused people not to be able to sit still. They bounced up out of their seats, knocking over ropes, dancing together.”

Allow them to air their views, and there is an excellent chance [they’ll] reciprocate.

Not everyone approves of Davis’ approach: Prominent Black Lives Matter activists criticize him, in the film, for paying attention to hatemongers who, they say, are incapable of change.

But Davis continues to believe otherwise, even in the face of rising incidences of racism-fueled violence around the country.

In the days after the presidential election, CNN reported, there was a 6 percent rise in reported hate crimes.

“None of the racism we’ve seen since the election has surprised me,” says Davis. “But I feel this election is one of the best things that has happened to this country — in that all of these people that most of our society has ignored or denied or turned a blind eye to are coming out of the woodwork. There’s no more denying it, or saying we live in a post-racist society. All you have to do is turn on the TV and see all these hate crimes.”

As for the rise of the so-called “alt-right,” Davis says, “That’s nothing new. It’s a new name for an old thing.”

Daryl Davis will do a Q&A with director Matthew Ornstein at Cinema Village on Friday after the 7:15 and 9:15 p.m. showings of the film and on Saturday at the 5:15 p.m. and 7:15 p.m. showtimes. 22 E. 12th St.; 212-924-3364, CinemaVillage.com