Only cash contributions (e.g., checks, credit card charges) are acceptable in 529 plans. You’ll have to sell the stock and donate the proceeds. If the stock has appreciated, you’ll owe capital gains tax on your profits; if the value has declined, you’ll be able to take a tax loss.
The difference between amount realized and adjusted basis on the sale or exchange of capital assets. Long-term capital gains are taxed favorably. Capital losses are deducted first against capital gains, and then again up to $3,000 of other income.