First off most of the information I have gleaned has come from here or the internet. This has worked for my setup and may not work for yours..
I wanted a seamless integration, no optical switchboxes, no new remotes etc.
You could be lucky and your TV may natively pass through HDMI 5.1 to TOSlink so try first before you buy any extras.
Basically the HDMI system does a HANDSHAKE when two items are connected, "most" TV's will be classed as a STEREO device because they only have two speakers; this is hard coded into the HDMI chip.. Anything connected to the TOS-LINK TV optical output after this is also classed as STEREO only including the Playbar/ Playbase.
When you connect a 5.1 capable source normally, it HANDSHAKES with the TV and the TV's HDMI EDID says "I've only got two speakers, pass me stereo only". This proves a problem when you own a Playbar..
I use a kwmobile EDID emulator, between the SOURCE (Blu-ray/ Set Top Box) and TV, when HANSHAKING now ths EDID emulator says "I'm a TV but capable of 5.1 surround".
The TV now has a full 5.1 sound input over HDMI and most can pass this through the Optical TOSlink to the Playbar.
With Blu-ray they are normally encoded with DTS which cannot be decoded with the Playbar, I chose to buy a Samsung BD-F6500 which has the option to downmix DTD to Dolby 5.1, it also has the Netflix APP which passes through 5.1 without issue from streamed content.
You will need one EDID emulator per HDMI input, but the beauty is you just use your TV as normal, no extra switches etc to control..