Polarization state generation and measurement with a single metasurface