ADV7513 Colour Correction  - Page 1
Forum section: electronics / beginners

author: ninja1980
author_rank: Newbie
timestamp: August 13, 2023, 01:06:11 pm
content: I'm very new into the world of FPGAs. I am trying use a 24bit RGB (4:4:4) signal which I've generated from the FPGA to feed into a ADV7513. I've managed to output a stable signal at 720p and 1080p. The only issue I'm having is the colour seems to be off in the output. I've captured the HMDI signal and I'm getting a discrepancy within the RGB values (it is also noticeable on the TV). All component values seem to be out, but the Red seems to be the most affected.I've been pulling my hair out over this for weeksDoes anyone have any experience with the ADV7513 or have any suggestions? It would be massively appreciated.

author: wasedadoc
author_rank: Super Contributor
timestamp: August 13, 2023, 02:32:11 pm
content: Are you running into the difference between the computer world and the TV world? The former uses the whole 0 to 255 range whereas the latter uses 16 for black level and 239 for peak white.

author: BrianHG
author_rank: Super Contributor
timestamp: August 13, 2023, 03:55:44 pm
content: Do you have the ADV7513's programmers guide?Did you try disabling the built in color space converter for a direct RGB drive?What the color error, is it off by a fixed fraction, or is it just wrong colors everywhere?Are you using it in HDMI or DVI mode?Did you set the HDMI mode to RGB or YUV?I've used the ADV7510 and AD7513 without color issues. You need to read their programmer's guide...Here is my simple AD7513 setup for dumb DVI/HDMI transmit mode. (HDMI mode enables audio support)Code:localparam HDMI_TABLE_len = 34 ; // Optional, length of init table.localparam bit [16:0] HDMI_TABLE_data [0:HDMI_TABLE_len-1] = '{ // Optional, init LUT data. 17'h {1'function,8'register_address,8'write_data},...// ADV7513 HDMI transmitter setup.17'h1_02FF, // Delay for 255 millisecond.17'h1_0072, // 4 Set ADV7513 HDMI transmitter's device address.// Program ADV7513 HDMI transmitter's registers.17'h0_9803, // Must be set to 0x03 for proper operation17'h0_0100, // Set 'N' value at 614417'h0_0218, // Set 'N' value at 614417'h0_0300, // Set 'N' value at 614417'h0_1470, // Set Ch count in the channel status to 8.17'h0_1520, // Input 444 (RGB or YCrCb) with Separate Syncs, 48kHz fs17'h0_1630, // Output format 444, 24-bit input17'h0_1846, // Disable CSC17'h0_4080, // General control packet enable17'h0_4110, // Power down control17'h0_49A8, // Set dither mode - 12-to-10 bit17'h0_5510, // Set RGB in AVI infoframe17'h0_5608, // Set active format aspect17'h0_96F6, // Set interrup17'h0_7307, // Info frame Ch count to 817'h0_761f, // Set speaker allocation for 8 channels17'h0_9803, // Must be set to 0x03 for proper operation17'h0_9902, // Must be set to Default Value17'h0_9ae0, // Must be set to 0b111000017'h0_9c30, // PLL filter R1 value17'h0_9d61, // Set clock divide17'h0_a2a4, // Must be set to 0xA4 for proper operation17'h0_a3a4, // Must be set to 0xA4 for proper operation17'h0_a504, // Must be set to Default Value17'h0_ab40, // Must be set to Default Value// 17'h0_af16, // Select HDMI mode17'h0_af14, // Select DVI mode17'h0_ba60, // No clock delay17'h0_d1ff, // Must be set to Default Value17'h0_de10, // Must be set to Default for proper operation17'h0_e460, // Must be set to Default Value17'h0_fa7d, // Nbr of times to look for good phase17'h1_0101 // Allow loop the reprogramming since the ADV7513 monitor HPD doesn't always work.};I2C utility:https://github.com/BrianHGinc/BHG_I2C_init_RS232_debugger

author: ninja1980
author_rank: Newbie
timestamp: August 14, 2023, 08:07:48 am
content: Thanks for the reply. The colour discrepancy seems to be mostly in the red space with HMDI output. I've followed the programming guide and I've extracted my current code below but I cant see any errors.Code:-- Select between YCbCr 4:2:2 and RGB 4:4:4 modesg_rgb444_support : if (RGB444 >= 2) generatecfg_ycbcr_mode <= not cfg_rgb444;end generate;g_no_rgb444_support : if (RGB444 <= 1) generatecfg_ycbcr_mode <= '1' when (RGB444 = 0) else '0';end generate;-- Instructionsdata <=("0000000001110100010010000010",-- Power-up the TXx"72" & "1" & x"41" & "1" & x"10" & "10",-- Fixed registers that must be set on power upx"72" & "1" & x"98" & "1" & x"03" & "10",x"72" & "1" & x"9A" & "1" & x"E0" & "10",x"72" & "1" & x"9C" & "1" & x"30" & "10",x"72" & "1" & x"9D" & "1" & x"61" & "10",x"72" & "1" & x"A2" & "1" & x"A4" & "10",x"72" & "1" & x"A3" & "1" & x"A4" & "10",x"72" & "1" & x"E0" & "1" & x"D0" & "10",x"72" & "1" & x"F9" & "1" & x"00" & "10",-- Set up the video input modex"72" & "1" & x"14" & "1" & x"02" & "10",x"72" & "1" & x"15" & "1" & x"3" & "000" & cfg_ycbcr_mode & "10",x"72" & "1" & x"16" & "1" & cfg_ycbcr_mode & "011" & x"9" & "10",x"72" & "1" & x"48" & "1" & x"0" & conv_std_logic_vector(1-ADV7513, 1) & "000" & "10",x"72" & "1" & x"BA" & "1" & x"A0" & "10",x"72" & "1" & x"D0" & "1" & x"3C" & "10",-- Set up the video output modex"72" & "1" & x"AF" & "1" & x"06" & "10",x"72" & "1" & x"55" & "1" & "00" & cfg_ycbcr_mode & "0" & x"0" & "10",x"72" & "1" & x"56" & "1" & x"08" & "10",x"72" & "1" & x"DE" & "1" & x"18" & "10",-- Audio setupx"72" & "1" & x"02" & "1" & x"10" & "10",x"72" & "1" & x"40" & "1" & x"80" & "10",x"72" & "1" & x"73" & "1" & x"01" & "10",-- Audio modex"72" & "1" & x"0C" & "1" & x"84" & "10",x"72" & "1" & x"0D" & "1" & x"10" & "10",-- Monitor sense inputx"72" & "1" & x"96" & "1" & x"20" & "10");

author: ninja1980
author_rank: Newbie
timestamp: August 14, 2023, 08:08:29 am
content: This is a really good point but I've tested both modes and it gives the same results.

author: BrianHG
author_rank: Super Contributor
timestamp: August 14, 2023, 02:49:27 pm
content: 17'h0_1630, // Output format 444, 24-bit input17'h0_1846, // Disable CSCThis bypasses all color processing. The data at the digital inputs are fed directly as HDMI/DVI data.I've been using it flawlessly. If you are using this, then the problem is on your other side.If you are transmitting YUV data, then you will be F-ed up as you then need to set the HDMI flags to tell the other side which color space you are using, ITU-R BT.601, or ITU-R BT.709. You also need to make sure you encode your source RGB into the appropriate color space. It gets worse, some TVs and capture cards may assume 709 even if you set 601 in the description header. You also need to set the amplitude, in the description header, 16-239, or 0-255, not to mention will your receiver respond automatically to the header, or assume a video signal where some may perform an auto black crush and auto contrast. All in all, there are something like 64 tables of CSC settings to cross accommodate all the possibilities from the different color standards and you need to get everything right or the picture may be pink looking, or green looking, pale, or too contrasty. Color bands will also appear from missing colors if you do not use RGB raw when you get the chance because any YUV conversion will only have around around 4 million colors out of the true 16million when sticking with RGB 0-255. This usually leads to circular bands when dealing with the lower shaded color or foggy scenes in video.