Now Reading
DisplayPort: Taming The Altmode | Hackaday

DisplayPort: Taming The Altmode | Hackaday

2023-08-04 02:39:56

The DisplayPort altmode is semi-proprietary, however it will possibly completely be picked aside if we attempt. Final time, we found a cool appnote describing the DisplayPort altmode in detail, switched the FUSB302 into packet sniffing mode and got packet captures, learned about PD VDMs (vendor-defined messages), and successfully replayed the captured messages to switch a USB-C port into the DisplayPort altmode. At this time, we’ll undergo the seven messages that summon the DisplayPort altmode, implement them, and tie all of them right into a library – then, work out the {hardware} we have to have DisplayPort work within the wild.

For a begin, as you may need seen from the diagram, a single command could be both a request or a response. As an example, if you happen to get a Uncover Id REQ (request), you reply to it with a Uncover Id ACK (response), including your identification information to your response alongside the best way. With some instructions, the DP supply will add some information so that you can use; for many instructions, your DP sink should present info as a substitute – and we’ll just do that, armed with the PDF offered and the packet captures.

We have now seven instructions we have to deal with with a purpose to get DisplayPort out of a suitable USB-C port – if you happen to want a refresher on these instructions, web page 13 of the ST’s PDF on the DP altmode will present you the message sequence. These instructions are: Uncover Id, Uncover SVIDs, Uncover Modes, Enter Mode, DP Standing Replace, DP Configure, and Consideration. Out of those, the primary 4 are already partially described within the base USB PD customary, the 2 DP instructions afterwards are DisplayPort-altmode-specific however sufficiently described within the PDF we’ve got, and the Consideration command is from the bottom customary as properly, largely useful for reporting state of the HPD pin. Let’s begin with the primary two!

The Discovery Course of

The primary two instructions are usually not DisplayPort-specific in any respect. Specifically, the Uncover Id message is omnipresent. Identical to with the Source_Capabilities message that we didn’t even must request from the PSU, if you happen to plug right into a USB-C port of a laptop computer able to DP and even Thunderbolt, you’ll obtain a Uncover Id command message. In case your system is able to dealing with any altmode, replying to this message is the way you announce this functionality.

Your Uncover Id response should comprise a bunch of knowledge about your system – most of this information, you’ll be able to outright faux. This information says that you just’re an alternate mode adapter, there’s two bits denoting whether or not you’re able to USB host or USB system operation, a “certification” discipline that may be left utterly empty, in addition to USB VID and PID. To my data, the VID and PID aren’t used for something feature-wise, in contrast to common USB connection PID and VID, which we all know for use for driver choice in working methods. The adapter that I’ve has vendor ID 0xBDA, product ID 0x2172 and bcdDevice quantity 0x201. These values are despatched as soon as, and don’t present up in any additional USB-C communications in anyway.

The second command is Uncover SVIDs – SVIDs are, primarily, two-byte codes for the the altmodes that your system helps. In case your reply is 0xFF01 (so, reply with 0xFF010000 as further information), you get a cookie, within the type of being acknowledged as a DisplayPort altmode-capable system. One of many gadgets I personal, solutions with 0xFF01, but additionally provides 0x25A4 to it – my suspicion is that this can be a firmware replace interface, so if you happen to ever wished to probe USB-C gadgets for pentesting functions, this could completely be a vector to look into.

DisplayPort Discovered – What’s Subsequent?

By giving the 0xFF01 reply to the Uncover SVIDs request, we declare that our system helps DisplayPort altmode – even when, fact be advised, we’re midway by way of correctly implementing it, faking it till we make it. No fear, although, as we’re heading in the right direction – now we’re speaking DisplayPort specifics. Our third command is Uncover Modes, the place we let the DP supply understand how precisely our DisplayPort wants map onto the USB-C connector.

Keep in mind how one can get full 4 lanes of DP from a USB-C connector, or do a 2-lane compromise however get USB3? Nicely, our Uncover Modes response determines precisely that. First, our response defines whether or not we’re a DP supply or DP sink – apparently, the protocol permits for constructing bidirectional DP gadgets, which is definitely idea-provoking! It additionally explicitly defines USB 2.0 signaling use, whether or not the USB3 port we would request would help USB3 Gen 2, and whether or not our system makes use of a USB-C plug or a USB-C socket. Most significantly, although, it talks concerning the pin mapping.

The DisplayPort altmode can have six pin mappings, 5 in case of a USB-C socket. Two of them are dual-lane DP with USB3 and three of them are four-lane DP. All of them have completely different lane preparations, apparently, however not less than a type of ought to work for us so long as we wire up our mux chip based on the datasheet. It’s not clear to me what the noteworthy variations are or why the assignments are completed the best way they’re completed – maybe, the unavailable full spec would have some insights. For now, this PDF offers us the mappings we are able to use, and the bits we must always set based on the mapping we’ve got chosen.

After answering the Uncover Modes message with information about our most popular pinout, we’ll shortly get an Enter Mode message – which we merely acknowledge with an Enter Mode response, no further information required. Now, in hacker voice, we’re in.

The Final Trio

The three final instructions are even nearer to the precise DisplayPort nitty-gritty. The primary one is DP Standing Replace, following proper after the Enter Mode command. We are able to get this command at any time when the DP sink desires to get an replace, and we’ll must reply it with our present hyperlink state. The bits on this command, as described on web page 11 of our by-now-favourite PDF, talk the present state of the DP altmode hyperlink. DP Standing Replace contents is a report on the general connection standing, each from the downstream standpoint (DP supply) and from the upstream standpoint (DP sink, aka our system). Right here we are able to exit the altmode if desired, change to USB mode, or maybe, to low-power mode, and we should additionally report the HPD pin state right here. All of that matches inside 9 bits of knowledge – not a lot to put in writing house about, however write house, you could.

The very first incidence of DP Standing Replace is uneventful, we simply wing it, telling that HPD is low and all that. It is going to be adopted by the DP Configure message – now, this level is the place we get entry to the uncooked DisplayPort sign on the SBU and high-speed pins of the USB-C port. The DP Configure message tells us which DP altmode pin mapping we must always change our {hardware} to, which is helpful in case we claimed to help a number of mappings in our Uncover Modes response – if we solely declare to help one, there shall be no surprises, except the DP supply doesn’t help the mapping we wished.

Final however not least, there’s the Consideration message – actually, bringing consideration to some occasion on our facet. The info for it’s the identical because the DP Standing Replace message – consider Consideration as a DP Standing Replace message that we are able to ship voluntarily at any time when one thing adjustments on our facet. So, in case you have a USB-C to DisplayPort socket adapter, the Consideration message would be the final message of the DP altmode summoning course of, letting the DP supply know that the supply has been linked. This, specifically is set by the HPD pin, one thing that’s used as a hotplug detection pin in DisplayPort, however can also be used for interrupts as a sideband to the AUX communication channel – as a pseudodifferential diffpair not in contrast to USB 1.1 and a pair of.0, the system on the opposite finish expects to be polled, and our Consideration messages will switch the HPD cries of the system that has one thing to say and however hasn’t but been requested to talk.

Now, we’re completed – that’s all seven messages described, and carried out in code as we did so. The entire altmode negotiation stream needs to be full inside a second’s time, or else the method will halt at some step. Which is to say, if you happen to’d wish to carry out some calculations or print information out, you higher be fast! Right here’s instance MicroPython code for you – one way or the other, I managed to have the parsing and command constructing be fast sufficient.

See Also

Thoughts you, that is the software program facet. Aside from what we simply did, let’s undergo a typical homegrown DP altmode design and what it wants.

{Hardware} Fundamentals

First off, you’ll wish to put the FUSB302 down in your schematic, and add a MCU to work with that. I normally choose a RP2040, however even an ESP12 module ought to do – you want I2C, just a few GPIOs for mux management, and a little bit of RAM for PD packet manipulation stuff. Then, after all, use a USB-C socket with high-speed lanes out there – common USB 2.0-only ports with 16 pins don’t expose the TX/RX pins we want. With regards to DisplayPort diffpairs, choose a six-layer board – you’ll need two outer layers for DisplayPort diffpairs, two layers below every for reference floor planes, and two innermost layers for routing out the VBUS, USB2, CC and SBU pins – fortunately, each Aisler and JLCPCB have first rate and low-cost six-layer choices now!

We are able to’t fairly purchase USB-C captive cables cheaply, sadly – nonetheless, placing a USB-C socket on our board is the subsequent neatest thing! You do want a bit of additional {hardware} although. Once more, the advantage of a captive cable shouldn’t be needing a mux – which implies that we are going to want a mux for dealing with our socket. After I was in search of USB-C muxes, I stumbled upon the VL170 chip, and pieced together its specifications from screenshots on-line. Later, I came upon that the VL170 is a clone of TI’s HD3SS460 (datasheet), and that’s what I like to recommend you employ – whether or not you wish to do 4-lane DisplayPort, or a USB3 and DisplayPort mixture, simply USB3, and even mix DisplayPort from two sources, the HD3SS460 mux will give you the results you want, and it has a correct datasheet with instance circuits.

Don’t floor the defend – it’s grounded at host finish as a rule, so it’s going to change into counterproductive given excessive speeds of DisplayPort. As a substitute, add a 0805 footprint or two going from the defend to floor; in a while, you’ll be able to put a ferrite there, or a resistor and capacitor mixture. With regards to high-speed alerts, the defend shall be performing the perform of defending your alerts from exterior interference; nonetheless, if you happen to floor it on each ends, it should additionally find yourself carrying a few of the VBUS present, which is able to scale back its shielding properties considerably. Oh, and about VBUS – it’s as much as you on what you’ll be doing with that, in spite of everything, the “PD controller” half shall be totally in your attain to start with; whether or not you summon 5 V, present 5 V, maybe request 20 V if you happen to’ve discovered a high-power and DP-capable port one way or the other, all of that’s utterly as much as you.

Route Your Tracks And You’re Completed

Keep in mind the DisplayPort hint routing guidelines? Nicely, the VL170 doesn’t fairly make it simple on you. Because of the the USB-C connector-side pair polarity on its pinout, solely two of its diffpairs join in an easy vogue – different two pairs must be flipped earlier than they join. Keep in mind, you continue to have to match lengths between the tracks, so you will have to regulate the half between the mux and the USB-C connector, and in addition the half between your your system and your mux. That mentioned, in a reference-ish design of mine, I’ve managed to maintain the connector-mux part to about one centimeter of size, so it shouldn’t be an excessive amount of of an area hog for you. As for the after-mux facet, you’d route the DisplayPort hyperlink the identical means you’d usually, not a lot of a distinction right here.

Are there additional bringup facets you may want? Completely! As an example, you may have to tune the common-mode voltages earlier than and after the mux utilizing just a few fastidiously matched resistors. Nonetheless, if you happen to ever wished to provide your system a DisplayPort hyperlink out of a USB-C connector, now you’re well-equipped to take action, no NDAs or proprietary doc acquisition wanted.

Source Link

What's Your Reaction?
In Love
Not Sure
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top