Sunday, October 18, 2015

usb host mode - How does MHL work?


I've done (quite) some googling, but I still don't get it. You need an MHL converter, or adapter, or something. On one end of the adapter, all resources say, there is a "standard micro-USB" port, and on the other a "standard HDMI port". If they are all so standard, what's the fuzz about 5-pins vs. 11-pins? The HDMI port must be standard for all displays to work with it I guess, so it must be something on the (apparently not so standard) micro-USB side in the phone. Looking in my phone, I can only see a 4-pins female micro-USB connector. Or are these 11 pins (I have a Galaxy Note II) buried somewhere deeper inside?


Secondly, there is often talk about this "switch" that's thrown as soon as an MHL adapter is connected. USB-OTG is disabled and it becomes a display input/output port only (input for the remote control, if available). I guess that means it's not possible to connect it through a USB hub to the phone? I need a bluetooth mouse and keyboard instead of a USB mouse and keyboard if I want to do this? Or is this only applicable for the 5-pins MHL devices, and is the point of the 11-pins one that I can connect my USB hub to the micro-USB port on the adapter?


Thirdly, I've also seen USB 2.0 to HDMI converters. They're twice as expensive as MHL, but they have a normal USB connection and output HDMI, so that would fit directly in my USB hub. (MHL would also fit through a microUSB->USB converter, but it seems there is something special about the micro-USB end that I don't get.) The question is whether my phone (a Galaxy Note II) has drivers for that kind of hardware, and whether the hub is fast enough. Any ideas?


Lastly, if anyone knows this, I'm curious about how this works on the inside. The graphics chip of the phone sends the video-out to its micro-USB port, just like it would with HDMI, or does it have some custom protocol that the MHL adapter then converts to HDMI? What about HDCP, how can you prevent someone from reading the output stream if every TV in the world can decrypt it already? Or is it like SSL a way to setup a secure connection to the TV so that others can't read your data stream if they were to capture it?




Answer



MHL is a new wire protocol, using very clever signalling technology to use very few wires to transmit a lot of data: 1080p video, 7.1 channel surround sound, and RCP remote control data. MHL also uses the existing power lines on USB to allow the TV to power the connected device.


When connected to an MHL display, the display controller on the phone speaks the MHL protocol just like it would speak the HDMI protocol to an HDMI display. The MHL standard itself is just the signalling protocol: it doesn't specify what connectors are used. This allows the micro-USB connector on a phone to detect when it's being used for MHL, and switch to speaking the MHL protocol. Apart from the connector, there's no relationship between MHL and USB, so you can't use a USB hub: the cable has to connect directly to the device.



HDCP on MHL works in exactly the same way as over an HDMI or DisplayPort connection: the intention is that only consuming devices with a valid, unrevoked device key can perform key exchange and thus decipher the content. See the Wikipedia page on HDCP if you want to learn about that, or about why the intended behaviour is not the actual behaviour.



There are three types of cable. The first is not an adaptor at all: it's just a cable for connecting an MHL producer such as a phone to an MHL consumer such as a TV. You can only use this if your TV supports MHL and has the appropriate connector.


The second is the 5-pin micro-USB-to-HDMI adaptor you've mentioned. You can still only use this if your TV supports MHL, but it means the TV doesn't need a special port. It doesn't use the HDMI protocol, or convert any signals: it's just a cable with a micro-USB connector on one end and an HDMI connector on the other.


The third is the 11-pin micro-USB-to-HDMI adaptor. This is needed for newer Samsung phones, which are incompatible with the 5-pin adaptors. Only the connection to the device is different: as far as the TV is concerned, it works the same as the 5-pin adaptor, and the TV must still support MHL. As you've surmised, the use for the extra pins is that 11-pin cables support using USB-on-the-go at the same time: the adaptor is Y-shaped, with a micro-USB connector at one end, and HDMI and micro-USB connectors at the other. The USB part works as normal and can be used with hubs, either in host mode or peripheral mode.


Illustration (credit: Rick Wessley) Illustrating the difference between micro-USB connectors




The other thing you've seen, a "USB to HDMI convertor", is for PCs. Software running on the PC acts as an extra framebuffer, and uses proprietary compression technology to compress the video stream so that it can be sent on a normal USB link. The compression protocol is secret, and optimized for sending computer GUIs rather than movies. The HDMI end of the convertor has enough processing power inside it to decompress the stream into a framebuffer, which it sends over HDMI to the connected screen. The technology is developed and owned by DisplayLink (formerly Newnham Technologies), based near me in Cambridge, GB.


Because they rely heavily on software running on the producer, they don't support Android, and likely never will. And because the compression protocol is secret and proprietary, the open-source community won't be able to supply a driver either. These devices use the standard USB protocol, so they work with hubs, but of course any delay or bandwidth contention caused by other devices will make the display laggy and add compression artifacts.


Since this answer was written, DisplayLink has released an Android solution that relies on an app running on the phone. They claim it works with all of their devices, but it seems to be mainly intended for their docking stations, not the HDMI adaptors.


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...