Farrah Fawcett's son Redmond O'Neal pleaded not guilty Thursday to felony heroin possession and will remain jailed until a hearing later this month.
O'Neal's attorney Richard Pintal said he hopes to reach a deal with prosecutors that includes additional treatment for his client, who had a string of drug arrests in recent years.
O'Neal also pleaded not guilty to a charge of being a felon in possession of a firearm. Police uncovered a 9mm handgun in a search of his apartment after his arrest Tuesday.
His father Ryan O'Neal and half-sister Tatum O'Neal also attended the hearing.
The 26-year-old was on probation for an incident in which he brought drugs to a detention facility north of Los Angeles. In that case, he was arrested in the parking lot of the facility while still under supervision for a previous drug arrest and an incident in which he and his father were arrested at the actor's Malibu home.
He was in jail in June 2009 when his mother died after a battle with cancer and was briefly released to attend her funeral.
Until his arrest by Santa Monica police on Tuesday, the younger O'Neal had stayed out of trouble for months. He was stopped after officers say they saw him run a red light, and a search of his car found the drugs, authorities have said.
He returns to court on Aug. 24 for a probation violation hearing and to try to resolve the current case, Pintal said.
O'Neal faces nearly four years in prison if convicted, but Pintal said he is hopeful a judge will order him to receive additional treatment.
"We remain cautiously optimistic and hopeful that there remains a possibility that a resolution can be structured that allows Mr. O'Neal to receive treatment rather than custody," Pintal said.