Photonic multiplexing and demultiplexing between free space and on-chip technologies