Published using Google Docs
HDMI2USB - Developers Guide
Updated automatically every 5 minutes

 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

www.mithis.com

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


 

General description

Atlys FPGA Board

IO connections

Status LEDs, Push buttons and Jumpers

Architecture

HDMI Matrix

EDID Hack

Flow chart of EDID Master

Flow chart of EDID Slave

Resolution Calculator

JPEG Encoder

Image Selector

Image Buffer

USB Top

Pattern Generator

Controller Top

// Edit by tija

Clock Domains of HDMI2USB

Building and configuration

Running of system

Webcam (UVC )

Serial Communication (CDC)

Components Address

USB Top commands

JPEG encoder commands

HDMIs

Source selector

RED, GREEN, BLUE commands

VGA daughter board commands(in progress)

Debug Module

Test setup

References and reading material


  1. General description

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.

  1. Atlys FPGA Board

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

  1. IO connections

        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.

Status LEDs, Push buttons and Jumpers

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.

  1. Architecture

        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.

  1. HDMI Matrix

        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

  1. EDID Hack

        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.

Flow chart of EDID Master

Flow chart of EDID Slave

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.

        

  1. Resolution Calculator

        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.

  1. JPEG Encoder

        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.

  1. Image Selector

        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.

  1. Image Buffer

        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.

  1. USB Top

        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.

  1. Pattern Generator

  2. Controller Top

// Edit by tija

Clock Domains of HDMI2USB

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:


  1. Building and configuration


https://github.com/timvideos/HDMI2USB/wiki/Digilent-Atlys-Board%3A-Loading-Firmware

  1. Running of system

bla bla...

  1. Webcam (UVC )

        bla bla bla

  1. Serial Communication (CDC)

        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

 

  1. Components Address

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

  1. USB Top commands

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

  1. JPEG encoder commands

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.

  1. HDMIs

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

  1. Source selector

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)

  1. RED, GREEN, BLUE commands

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

  1. VGA daughter board commands(in progress)

The Table below shows the possible commands for VGA daughter board.

Command

Description

Not in use/ Reserved for future use

  1. Debug Module

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

  1. Test setup


  1. References and reading material

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.