He's had his card marked

Where does the phrase "he's had his card marked" come from?

I am wondering if this is the same as using a marked deck or having marked cards. Cheating at a card game, in other words.

OR if it is like having your ticket punched.