Your son received a scholarship in the amount of $8k. $7,995 of that was spent on qualified (for a tax-free scholarship) expenses: tuition, mandatory fees, and books. That leaves $5 of the scholarship that will be taxable.
Room and board was $7k, which you paid with 529 money. That works, because room and board is a 529 qualified expense. It sounds like you withdrew an additional $8k from the 529 because of the $8k scholarship that was received. You can avoid the additional 10% tax on that non-qualified 529 withdrawal to the extent that it matches up to a tax-free scholarship. $7,995 of the scholarship was tax-free, so you can avoid the 10% additional tax on $7,995 of the non-qualified 529 withdrawal. If $2k (25%) of the $8k non-qualified 529 withdrawal represents the earnings portion of that withdrawal, tax will be paid on $2k, and the additional 10% tax will be paid on 25% of the amount ($5) that is not covered by tax-free scholarship.