Train driver Francisco Jose Garzon Amo was among those injured in the crash
The driver of a train that derailed on Wednesday killing 78 people has been formally detained, Spanish police say.
The driver, who was injured and is under guard in hospital, is accused of "crimes related to the accident", they say.
There are reports that the train was travelling at more than double the speed limit at the time of the crash.
Spain has declared three days of national mourning over the crash, one of its worst-ever rail disasters.
The police chief in the Galicia region, Jaime Iglesias, said on Friday that driver Francisco Jose Garzon Amo would be questioned "as a suspect for a crime linked to the cause of the accident".
He added that Mr Garzon could not yet testify because of his medical condition.
Police also put the confirmed number of deaths at 78 - down from 80 announced earlier.
They said the difference arose because human remains had been wrongly identified in the initial stages.
At least 130 people were taken to hospital after the accident near the north-western city of Santiago de Compostela, and 95 are still being treated.
The 32 seriously injured include children. People from several nationalities are among the wounded, including five Americans and one Briton. One American was among the dead.
On Thursday junior transport minister Rafael Catala said early indications suggested the train had been going too fast.
The Madrid to Ferrol train's data recording "black box" is now with the judge in charge of the investigation.
It is unclear whether anyone else is subject to investigation.
The president of railway firm Renfe, Julio Gomez Pomar, was quoted by El Mundo newspaper as saying the 52-year-old driver had 30 years of experience with the company and had been operating trains on the line for more than a year.
He said the train which derailed had no technical problems.
Renfe said the train came off the tracks about 3 or 4km (2-2.5 miles) from Santiago de Compostela station at 20:41 local time (18:41 GMT) on Wednesday.
It was on the express route between the capital, Madrid, and the port city of Ferrol on the Galician coast, with 218 passengers on board and four crew.
The derailment happened on the eve of Santiago de Compostela's main annual festival where thousands of Christian pilgrims were expected to flock to the city in honour of St James.