Mark Salling has plea bargained his child pornography case ... pleading guilty to possession of child pornography involving a prepubescent minor.
Salling had been charged with 2 counts of child porn after cops found more than 50,000 images of child pornography and child erotica on his personal computer.
He has agreed to make restitution to the victims, which is $50k per victim -- presumably the children in the photos.
He was facing 20 years in prison. Salling and prosecutors agreed the appropriate sentence should be 4 to 7 years in prison ... with 20 years of supervised release.
As a condition of his supervised release he will be registered as a sex offender -- and also will not be allowed to live within view of school yards, parks, public swimming pools, playgrounds, video arcades, or any other places frequented by people under age 18.
The sentence is ultimately up to a judge.