RGB to HDMI using a Pi Zero and a small CPLD

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
Post Reply
User avatar
Elminster
Posts: 3137
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by Elminster » Sat Jul 14, 2018 12:35 pm

Looking good. Finished breaking Daniel’s projects for now so ready to start breaking this.

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sat Jul 14, 2018 2:17 pm

Elminster wrote:
Sat Jul 14, 2018 12:35 pm
Looking good. Finished breaking Daniel’s projects for now so ready to start breaking this.
That won't be hard!

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sat Jul 14, 2018 4:29 pm

Here's a quick question for anyone getting an RGBtoHDMI in the hear future.....

Can you tell me what the "native" resolution of your HDMI monitor is?

I just want to check these resolutions work, and head off any possible issues with certain resolutions that are difficult to make good use of.

If you don't know the resolution, just post the TV/monitor model number and I can look it up.

Dave

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Sat Jul 14, 2018 6:32 pm

Main Tis is1920x1080, can't check monitor at the mo.
I did have a mad thought about the new 1024x768 HDMI panel and adapter from pimoria pimoroni and a luggable Beeb.

EDIT: I also have a 1920x1200 DVI monitor.
Last edited by tricky on Sat Jul 14, 2018 6:51 pm, edited 1 time in total.

User avatar
BigEd
Posts: 2139
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by BigEd » Sat Jul 14, 2018 6:44 pm


Budgie
Posts: 79
Joined: Mon Nov 02, 2015 9:14 pm
Location: Manchester, UK
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by Budgie » Sat Jul 14, 2018 6:44 pm

Mine is also 1920x1080. I have a few though so can test a number of options possibly. I think they are all 1080p so may all be the same !

User avatar
KenLowe
Posts: 378
Joined: Mon Oct 18, 2004 4:35 pm
Location: Scotland
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by KenLowe » Sat Jul 14, 2018 6:45 pm

hoglet wrote:
Sat Jul 14, 2018 4:29 pm
Can you tell me what the "native" resolution of your HDMI monitor is?
Are you considering monitors with DVI inputs as HDMI? From a video perspective, I understand that they're the same My DVI monitor has some odd native resolution. If it's relevant, I'll get you the details tomorrow.

User avatar
myelin
Posts: 461
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by myelin » Sat Jul 14, 2018 7:08 pm

1920x1080 here!
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sat Jul 14, 2018 7:40 pm

KenLowe wrote:
Sat Jul 14, 2018 6:45 pm
Are you considering monitors with DVI inputs as HDMI? From a video perspective, I understand that they're the same My DVI monitor has some odd native resolution. If it's relevant, I'll get you the details tomorrow.
Yes, it's definitely possible to use a DVI monitor with a suitable mini-HDMI to DVI cable.

What I'm trying find out is whether anyone will be try to use a monitor that's less than full HD (1920x1080).

The reason is that internally RGB-to-HDMI uses a 672x540 framebuffer, and to look it's best you want the Pi to be scaling by a factor of 1x, 2x or 3x. Resolutions like 1280x720 and 1360x768 are therefore potentially problematic, in that either you will have huge black borders, or there will be obvious scaling artifacts.

Dave

User avatar
KenLowe
Posts: 378
Joined: Mon Oct 18, 2004 4:35 pm
Location: Scotland
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by KenLowe » Sat Jul 14, 2018 7:55 pm

I'm pretty sure my primary beeb DVI monitor is native 1600 x ???. It's a Philips model bought from Costco many years ago. I'll be able to verify model / resolution tomorrow. I've also got a few TV's and monitors that are native 1920 x 1080 and also a native 4k TV that I can test with. In fact, thinking about it I've got a stack of old different Dell DVI monitors with varying 4x3 and 16 x 10? resolutions, and all are less than 1920.

User avatar
Elminster
Posts: 3137
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by Elminster » Sat Jul 14, 2018 8:00 pm

A random 12inch monitor designed for CCTV's from some site on ebay. Unbranded. Will have to work it out when I have a moment.

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sat Jul 14, 2018 8:03 pm

Elminster wrote:
Sat Jul 14, 2018 8:00 pm
A random 12inch monitor designed for CCTV's from some site on ebay. Unbranded. Will have to work it out when I have a moment.
That's very likely 1366x768, so let the fun begin!

User avatar
trixster
Posts: 648
Joined: Wed May 06, 2015 11:45 am
Location: York
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by trixster » Sat Jul 14, 2018 9:50 pm

Are they all gone Dave or is it possible to bag the last one for testing?! :)

PM sent. My tv is 1920x1080p, my monitor is 1600x1200 (i’d use a hdmi-dvi adapter on that).

Andy
Last edited by trixster on Sat Jul 14, 2018 10:03 pm, edited 2 times in total.
A3020 | A3000 | A420/1 | BBC B + 128K RAM/ROM + 20K Shadow + Pi0 + VideoNuLA
Master Turbo + DC + BeebSID | Atom | A4000 060 | A3000 060 | A1200 060 | A500
Atari Falcon 060 | Saturn | PS1 | SNES | CPC6128 | C64 | 3DO | MD | Jaguar

User avatar
Elminster
Posts: 3137
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by Elminster » Sat Jul 14, 2018 11:18 pm

Elminster wrote:
Sat Jul 14, 2018 8:00 pm
A random 12inch monitor designed for CCTV's from some site on ebay. Unbranded. Will have to work it out when I have a moment.
I should have said the Electron is plugged into the above monitor via composite. So using the pi I hope to plug into the monitors hdmi for full colour.

The master could be more interesting ... it is not on a monitor as such but runs as a Java application on a red hat vm on a Mac under VMWare. It gets there via RGB to scart, into a scart to hdmi convector, then changed to vga, then into an avocet network kvm. From there displayed on Mac as already mentioned. This one good be a fun test for the pi. It cuts out a couple of step. But can also be test on the monitor as well.

If none work I shall go grab the 19inch lcd from my daughter.

PhilYoung
Posts: 195
Joined: Sun Jun 12, 2011 4:55 pm
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by PhilYoung » Sun Jul 15, 2018 8:53 am

hoglet wrote:
Sat Jul 14, 2018 4:29 pm
Here's a quick question for anyone getting an RGBtoHDMI in the hear future.....

Can you tell me what the "native" resolution of your HDMI monitor is?

I just want to check these resolutions work, and head off any possible issues with certain resolutions that are difficult to make good use of.

If you don't know the resolution, just post the TV/monitor model number and I can look it up.

Dave
I'd probably intend to get or build one of these eventually, my HDMI monitor (which is a repurposed laptop LCD) is 1280x800 which is a resolution that hasn't been mentioned yet. Do you forsee any problems with that - it works fine with a Raspberry Pi running Raspbian.

Cheers,

Phil

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sun Jul 15, 2018 9:50 am

PhilYoung wrote:
Sun Jul 15, 2018 8:53 am
[I'd probably intend to get or build one of these eventually, my HDMI monitor (which is a repurposed laptop LCD) is 1280x800 which is a resolution that hasn't been mentioned yet. Do you forsee any problems with that - it works fine with a Raspberry Pi running Raspbian.
1280x800 is slightly problematic: you will get a picture, but there may well be scaling artefacts.

RGBtoHDMI digitises the Beeb's video to 672x540 internally, and then the Pi's GPU scales that up to the monitor resolution, less any configured overscan.

(It's 672 horizontally rather than 640 to allow for slight differences in horizontal positioning of modes 0..6)

(It's 540 vertically rather than 512 to allow for *TV 1 without cropping, though *TV 255 does crop a bit)

Ideally, by tweaking the overscan you end up with each sampled Beeb pixel mappng to an integer number of monitor pixels, e.g. 1x1 or 2x2 etc.

If you do the sums with 1280x800, the numbers don't work out nicely. You'll end up having to choose between large borders (i.e. lots of overscan) or some scaling artefacts.

Dave
Last edited by hoglet on Sun Jul 15, 2018 9:50 am, edited 1 time in total.

User avatar
BigEd
Posts: 2139
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by BigEd » Sun Jul 15, 2018 10:11 am

I think you've said previously, Dave, that there's not much time left for the Pi's ARM CPU to do much if any image processing and still keep up with the frame rate. And while the GPU is surely capable of sophisticated rescaling, there's no documentation for a baremetal program to make use of.

Is there any CPU time left at all? Is there any unsophisticated scaling available from the GPU?

There's some discussion of rescaling in the NetPBM package here (about 20 methods!) and, possibly of theoretical interest, a collection of approaches to upscaling pixel art images here. (It's possible that for our purposes, a pixel-art upscaling followed by a conventional fractional downscaling would be best. If only we had the machinery.)

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sun Jul 15, 2018 10:12 am

tricky wrote:
Tue Jul 10, 2018 5:25 am
I was only looking to match a CRT, which would be twice the current resolution. Being able to do better would be nula territory. I'm not promising that I won't ask for it in future, or saying that nobody wants it now ;)

From the CRT experiments that I have done, +/-1 on the width is OK. I did find one TV that wasn't keen on one of them, but was fine with the other.

For comms, +/-2 width, cancelled out by -/+1 position would need to be recognisable, but not cause any change in the display. I guess other methods could be used, this was just my first thought.

It seems to me that eight copies of the loop would be feasible should someone want it in the future. If they (I) do then, horizontal blanking would also be handy ;)
I've just been doing some further testing of the different sync pulse widths, and hit some problems in Modes 4/5/6.

It's possible I'm using the wrong values though.

Does the sub-character scrolling scheme just involve changing the sync pulse width, or do you also end up changing other things?

In Mode 0..3, I'm testing with R3=&28 (normal) and R3=&29 (longer). The longer pulse has the effect of shifting the screen to the left by 4 16MHz pixels.

In Mode 4..6, I'm testing with R3=&24 (normal) and R3=&25 (longer). I'm hitting an issue where RGBtoHDMI is falsely detecting the longer sync pulse as a change to Mode 7. i.e. the "trick" I'm using to detect Mode 7 sees a false positive with 5us sync pulses. I need to check why this is.

But before I dived into this further, I wanted to check with you that the register values are reasonable. And also whether you are also varying the sync position (R2) as well.

Dave

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sun Jul 15, 2018 10:16 am

BigEd wrote:
Sun Jul 15, 2018 10:11 am
I think you've said previously, Dave, that there's not much time left for the Pi's ARM CPU to do much if any image processing and still keep up with the frame rate. And while the GPU is surely capable of sophisticated rescaling, there's no documentation for a baremetal program to make use of.
By default, the GPU does a pretty good job I think of scaling from the frame buffer size 672x540 (or 504x540 in mode 7) to the final HDMI resolution (less the specified overscan).

It's only if you put up a killer test image e.g. alternating lines that you really notice.

I doubt anything we could do in software would be as good.

User avatar
BigEd
Posts: 2139
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by BigEd » Sun Jul 15, 2018 10:40 am

Just a thought - if we line-doubled to x1080 so the GPU is always down-scaling in the Y direction, is that any better? (And, is there time to do it...)

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Sun Jul 15, 2018 12:27 pm

I nearly always change the h-sync pulse position as my screen is usual 4/5 the default width.
I think supporting this for modes 0, 1 and 2 is most useful, after that the jump is quite large and software is more feasible.
I will be offering other options for width and position in Rally-X, but having what you support as the default is fine.
It might be worth testing the 1,000 scroll demo in 3D Pool.

PhilYoung
Posts: 195
Joined: Sun Jun 12, 2011 4:55 pm
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by PhilYoung » Sun Jul 15, 2018 12:35 pm

hoglet wrote:
Sun Jul 15, 2018 9:50 am
PhilYoung wrote:
Sun Jul 15, 2018 8:53 am
[I'd probably intend to get or build one of these eventually, my HDMI monitor (which is a repurposed laptop LCD) is 1280x800 which is a resolution that hasn't been mentioned yet. Do you forsee any problems with that - it works fine with a Raspberry Pi running Raspbian.
1280x800 is slightly problematic: you will get a picture, but there may well be scaling artefacts.
<details snipped>
Dave
Thanks for the explanation, I'll just have to try it, eventually, and see how it looks.

Cheers,

Phil

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sun Jul 15, 2018 12:42 pm

PhilYoung wrote:
Sun Jul 15, 2018 12:35 pm
Thanks for the explanation, I'll just have to try it, eventually, and see how it looks.
I've just tried 1280x720 on my old Sony Bravia (which is then scaled to 1360x768). It actually didn't look too bad. Certainly better then when using the SCART input.
Last edited by hoglet on Sun Jul 15, 2018 12:43 pm, edited 1 time in total.

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sun Jul 15, 2018 12:48 pm

tricky wrote:
Sun Jul 15, 2018 12:27 pm
It might be worth testing the 1,000 scroll demo in 3D Pool.
OK, that's looking a bit more jerky (both horizontally and vertically) than when using the SCART input.

Do you know how this demo works?

On the Horizontal, the CPLD starts it's counting on the trailing (rising) edge of Hsync. I'm actually wondering now if that's correct. I wonder if the LCD is using the other edge.

Might try a small tweak to the CPLD to see if that improves things.

Dave

User avatar
KenLowe
Posts: 378
Joined: Mon Oct 18, 2004 4:35 pm
Location: Scotland
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by KenLowe » Sun Jul 15, 2018 12:54 pm

Ok, So I've got the following DVI monitors with native resolutions:
  • Philips Brilliance 200W - 1680 x 1050 (16 x 10)
  • Dell 2009Wt - 1680 x 1050 (16 x 10)
  • Dell 1908WFPf - 1440 x 900 (16 x 10)
  • Dell 2007FP - 1600 x 1200 (4 x 3)
and HDMI TVs with the following native resolutions:
  • LG 55EG920V-ZA - 3840*2160 (16 x 9)
  • Panasonic TX-P46G15B - 1920 x 1080 (16 x 9)
I have other monitors & TVs, but not checked those out yet. I'll update this post if I get time.
Last edited by KenLowe on Sun Jul 15, 2018 1:18 pm, edited 1 time in total.

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sun Jul 15, 2018 1:12 pm

hoglet wrote:
Sun Jul 15, 2018 12:48 pm
tricky wrote:
Sun Jul 15, 2018 12:27 pm
It might be worth testing the 1,000 scroll demo in 3D Pool.
OK, that's looking a bit more jerky (both horizontally and vertically) than when using the SCART input.
...
Might try a small tweak to the CPLD to see if that improves things.
Starting the CPLD counting from the leading (falling) edge of hsync has really helped with the horizontal issues with 3D Pool. But it seems to have broken the smooth scrolling in RallyX. Now, I can fix this by inverting the logic re the short vs long sync pulse, but I don't want to do this blindly.

Tricky, here's a specific question for you:

The normal value of R3 is &28, giving a 4us sync pulse. If I write this register to &29, giving a 4.5us sync pulse, would you expect the screen to move to the left or to the right (if nothing else changes)?

Dave

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sun Jul 15, 2018 1:46 pm

The book Video Demystified (pdf) says:
HSYNC# is asserted during the horizontal sync time each scan line, with the leading edge indication the start of a new line.
and
To ensure compatibility between various sources, horizontal counter should be reset by the leading edge of HSYNC#, not by the trailing edge of BLANK#.
Which was not what I was previously doing.

Of course, this only starts to make a difference when you have a game that varies the width of the sync pulse.

All fixable, but I'm glad to have found this before I sent the boards out!

Dave
Last edited by hoglet on Sun Jul 15, 2018 1:47 pm, edited 1 time in total.

User avatar
KenLowe
Posts: 378
Joined: Mon Oct 18, 2004 4:35 pm
Location: Scotland
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by KenLowe » Sun Jul 15, 2018 1:51 pm

hoglet wrote:
Sun Jul 15, 2018 1:12 pm
All fixable, but I'm glad to have found this before I sent the boards out!
Good that you've found this info! Hopefully that will address the issues you were seeing. Will the CPLD be end user re-programmable if we do need to make any updates once you've sent the boards out?

User avatar
hoglet
Posts: 7600
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sun Jul 15, 2018 2:11 pm

KenLowe wrote:
Sun Jul 15, 2018 1:51 pm
hoglet wrote:
Sun Jul 15, 2018 1:12 pm
All fixable, but I'm glad to have found this before I sent the boards out!
Good that you've found this info! Hopefully that will address the issues you were seeing. Will the CPLD be end user re-programmable if we do need to make any updates once you've sent the boards out?
Yes it is, but you need a Xilinx programming cable which costs £18 (and is useful across many projects):
https://www.ebay.co.uk/itm/Xilinx-Platf ... 2154533106

Dave

User avatar
KenLowe
Posts: 378
Joined: Mon Oct 18, 2004 4:35 pm
Location: Scotland
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by KenLowe » Sun Jul 15, 2018 2:25 pm

Thanks Dave. I'll get one of those ordered up to join the growing collection of programmers that I've bought recently (USB Blaster for VideoNuLA & USBasp for Speech PHROM).

Post Reply