All current development is on the MiSoC based firmware.
This document is obsolete
(as of 2015-12-01) and for the old Jahanzeb firmware.
See the “History” section of the HDMI2USB.tv website for more information.
MITHIS
709, 243 Pyrmont Street
Pyrmont, NSW, 2009
AUSTRALIA
HDMI2USB
A HDMI/DVI Capturing Solution
Lead designer Jahanzeb Ahmad
Documentation by (Feel free to improve and add your name)
Jahanzeb Ahmad
Tim ‘mithro’ Ansell
Status LEDs, Push buttons and Jumpers
VGA daughter board commands(in progress)
References and reading material
HDMI2USB is a device to capture HDMI and DVI (and Displayport through cheap active adapters) and send it on USB port as UVC video. The device attaches computer as a standard webcam so there is no need of installing additional drivers. At the same time it also attaches to computer as a CDC serial device to communicate and check the status of different modules.
Current design is based on Digilent Atlys board although custom device is under development. For more information on Atlys visit www.digilentinc.com/ATLYS/. LED4 - Flab C (Empty Flag) of cypress USB device.
LED5 - SLWR signal to cypress USB device.
LED7:6 - Combination of LED7 and 6 tells which input source is selected as output to HDMI matrix and USB.
LED7, LED6 | Selected Input |
Off, Off | HDMI 0 |
Off, On | HDMI 1 |
On, Off | Reserved (for VGA extension board) |
On, On | Test pattern |
Two HDMI inputs and Two HDMI outputs can be connected to the board. Output video is streamed on USB port using uvc. Same USB port is first used to program the device. see section 3 for more details. The diagram below shows the connections of HDMI and USB.
LED0 - Indicates HDMI 0 input is connected.
LED1 - Indicates HDMI 1 input is connected.
LED2 - If on then UVC is MJPEG if off then output is RAW.
LED3 - Flab B (Full Flag) of cypress USB device.
BTNU - Selects HDMI 0 as output.
BTNL - Selects HDMI 1 as output.
BTND - Selects test pattern as output.
BTNC - If pressed emulates display connection to read edid structure.
Jumper J6 and J7 should be open to allow the EDID master slave to work properly.
Jumper J5, SCL and SDA should be close so that HDMI source can read EDID from FPGA.
The system is designed in VHDL and Verilog. Each component of the design is described in detailed. The block diagram of the system is shown in figure below.
ATLYS has two input ports and two output ports. The two output ports are identical and can be selected from either HDMI inputs either by CDC serial communication or by buttons BTNU and BTNL. This module is modified version of Xilinx Application note xapp495 complete details of the implementation can be found on
http://www.Xilinx.com/support/documentation/application_notes/xapp495_S6TMDS_Video_Interface.pdf
EDID stand for Extended Display Identification Data. Used to identify capabilities of the display device using I2C bus. More information on http://en.wikipedia.org/wiki/EDID.
Edid hack is made of two components EDID Master and EDID Slave. EDID master reads the EDID structure from display device and EDID slave sends the appropriate structure to the computer based on the structure read from display device. If no display device is connected HDMI2USB sends EDID structure with resolution of 1024x768. Flow charts of the master and slaves are shown below.
EDID hack is only used for HDMI 0, EDID Hack is not implemented on HDMI 1 because I2C pins for HDMI 1 on ATLYS are connected.
Resolution calculator calculates the resolution of HDMI inputs using rising edges of horizontal and vertical syncs. The resolution of the input HDMIs can be read from the system using reading the status of HDMIs.
An open source JPEG encoder from opencores is used in this system. Detailed information and documentation of JPEG encoder is available at http://opencores.org/project,mkJPEG. JPEG encoder is considered as a black box. A top module on black box is created consisting of a state machine to communicate with controller and USB data transfer. The state machine of the JPEG encoder top is shown below.
Image selector selects the source for HDMI out and JPEG encoder or raw uvc output. It also processes the image data if required before passing it to HDMI output and image buffer for transfer it to USB ot JPEG encoder. The block diagram of the module shows the processing and selection of image data.
The image buffer stores the image into DDR2 ram on the ATLYS board. This module is composed of XIlinx MIG core, input fifo for data and two independent state machines. For more information on Xilinx MIG core consult ug416 and ug388 Xilinx user guide.
Write state machine is shown in flowchart below.
Read state machine is shown in the flowchart below.
USB Top is composed of a state machine and four sub modules each submodule has its own state machine. The block diagram of the USB top is shown in figure below.
To change the DDR2 Clock and img_clk, one has to change the following parameters in ipcore_dir/ddr2ram/user_design/rtl/ddr2ram.vhd
constant C3_CLKOUT0_DIVIDE : integer := 1; --sysclk_2x = 625 MHz
constant C3_CLKOUT1_DIVIDE : integer := 1;--sysclk_2x_180 = 625 MHz
constant C3_CLKOUT2_DIVIDE : integer := 8;--img_clk = 78.125 MHz
constant C3_CLKOUT3_DIVIDE : integer := 4;--calibration clock = 156.25 MHz
constant C3_CLKOUT4_DIVIDE : integer := 25; -- ignore this
constant C3_CLKFBOUT_MULT : integer := 25;--clk multiplier
constant C3_DIVCLK_DIVIDE : integer := 4;--clk divider, so output =100*25/4=625
Other clock signals:
https://github.com/timvideos/HDMI2USB/wiki/Digilent-Atlys-Board%3A-Loading-Firmware
bla bla...
bla bla bla
Instruction is based on a two ASCII bytes. Each instruction has two parts 1 byte address and one byte command. The LS byte is command and MS byte is address.
Address | Command |
The table below shows the assigned address in the system.
Address | Assigned to |
U | u | USB Top |
J | j | JPEG encoder |
H | h | HDMI |
S | s | Source selector |
R | r | Red Color |
G | g | Green Color |
B | b | Blue Color |
D | d | Debug Module |
The Table below shows the possible commands for controller and USB module.
Command | Description |
J | j | Force JPEG output |
R | r | Force RAW output |
N | n | Turn on Video output |
F | f | Turn off Video output |
V | v | UVC header on (video) |
I | i | UVC header off (Image) |
S | s | Return the Status of the USB top |
H | h | Force current HDMI selected source to 720p |
D | d | Force current HDMI selected source to 1024x768 |
USB status command returns One byte status but only three Least Significant bits contains the information about the module as shown in table below.
7-3 | 2 | 1 | 0 |
0 | 1 - Output Enable 0 - Output Disable | 1 - Output JPEG 0 - Output Raw | 1 - UVC Header enabled 0 - UVC Header disabled |
The Table below shows the possible commands for JPEG Encoder.
Command | Description |
S | s | Returns the status of the JPEG encoder. |
0 | Encoding quality 100% |
1 | Encoding quality 85% |
2 | Encoding quality 75% |
3 | Encoding quality 50% |
JPEG Encoder module only returns one byte if status with only two least significant bit containing information. These decimal value(3-0) of two least significant bits tells the quality of encoding.
The Table below shows the possible commands for HDMIs.
Command | Description |
S | s | Returns the status of the module. |
0 | Force HDMI 0 to 720p[1] |
1 | Force HDMI 0 to 1024[2] |
2 | Force HDMI 1 to 720p[3] |
3 | Force HDMI 1 to 1024[4] |
HDMI module returns 265 Bytes:
Byte | Description |
0 - 127 | EDID structure of HDMI 0 |
128 - 256 | EDID structure of HDMI 1 |
257 | In this byte only two least significant bits contain information. If Bit 0 is 0 then HDMI in 0 is forced to HDMI else DVI resolution same is for bit 1 for HDMI 1 |
258 | Most Significant byte of horizontal resolution of HDMI 0. |
259 | Least Significant byte of horizontal resolution of HDMI 0. |
260 | Most Significant byte of Vertical resolution of HDMI 0. |
261 | Least Significant byte of Vertical resolution of HDMI 0 |
262 | Most Significant byte of horizontal resolution of HDMI 1. |
263 | Least Significant byte of horizontal resolution of HDMI 1. |
264 | Most Significant byte of Vertical resolution of HDMI 1. |
265 | Least Significant byte of Vertical resolution of HDMI 1 |
The Table below shows the possible commands for image selector.
Command | Description |
S | s | Returns the status. |
U | u | Selects HDMI 0 as output (can also be selected using BTNU on Atlys) |
D | d | Selects Test pattern as output (can also be selected using BTND on Atlys) |
L | l | Selects HDMI 1 as output (can also be selected using BTNL on Atlys) |
G | g | Force Gray output |
C | c | Force Color output |
I | i | Invert colors |
H | h | Turn on/off heart beat (Will work only when sw=1) |
Source selector returns Two bytes
Bit | Description |
1:0 | Selected source , 00 = Hdmi 0, 01 = Hdmi 1, 11 = test pattern |
2 | Output Gray(0) or Color(1) |
3 | inverted(1) / non-inverted color(0) |
5:4 | Blue Depth, 00 = 256, 01 = 32, 10 = 16, 11 = 8 colors |
7:6 | Green Depth, 00 = 256, 01 = 32, 10 = 16, 11 = 8 colors |
9:8 | Red Depth, 00 = 256, 01 = 32, 10 = 16, 11 = 8 colors |
10 | Blue on(1) /off(0) |
11 | Green on(1) /off(0) |
12 | Red on(1) /off(0) |
These are the common commands for all three colors.
Command | Description |
N | n | Turn on this color |
F | f | Turn off this color |
0 | 256 colors per color |
1 | 32 colors per color |
2 | 16 colors per color |
3 | 8 colors per color |
The Table below shows the possible commands for VGA daughter board.
Command | Description |
Not in use/ Reserved for future use |
The Table below shows the possible commands for VGA daughter board.
Command | Description |
S | s | Outputs Debug Data |
The output of Debug Module is 14 bytes:
Byte | Description |
1 | Device State |
5:2 | Resolution of Source |
6 | Input frame rate in fps |
7 | Output frame rate in fps |
8 | Frame write time in ms |
9 | Frame Processing Time in ms |
10 | No. of frames dropped for every frame processed |
13:11 | No. of bytes in a frame |
This document is obsolete
[1] This needs manually removing and reconnecting HDMI cable. As HPD pin of HDMI is hardwired in Atlys.
[2] This needs manually removing and reconnecting HDMI cable. As HPD pin of HDMI is hardwired in Atlys.
[3] This needs manually removing and reconnecting HDMI cable. As HPD pin of HDMI is hardwired in Atlys.
[4] This needs manually removing and reconnecting HDMI cable. As HPD pin of HDMI is hardwired in Atlys.