RGB to HDMI using a Pi Zero and a small CPLD

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
User avatar
hoglet
Posts: 7121
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 » Fri May 11, 2018 4:55 pm

Budgie wrote: See below the test pattern (bottom only) after switch on and then after a calibration (i.e. pushing the button). Not sure why it doesn't calibrate on switch on ?
Is the second image after calibration? If so, then something is wrong as it has picked the worst possible sampling point!

Can you grab the debug log of the calibration?

There is a reason it doesn't currently calibrate on reset, but not a very good one. On my system I'm powering the Pi and CPLD from the +5V on the Beeb's RGB connector. I found that when you switch the Beeb on, the Pi actually boots before there is anything on the screen. The calibration doesn't work with a blank screen. I was intending to do an autocalibration after a few seconds, but haven't got around to implementing this yet.
Budgie wrote: Interestingly or not so interestingly I've just zapped my CPLD switching the beeb off of all things. I've only got RGB and SYNC connected not GND and 5V from the RGB connector. Not sure whether some suppression would be worth having on the PCB from the connector. May have been a one off as I do mess around a lot with this board.
You definitely need to have a GND connection from the Beeb's to the CPL board at all times. Omitting this probably what zapped the CPLD.

Dave

User avatar
Richard Russell
Posts: 228
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

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

Post by Richard Russell » Fri May 11, 2018 5:48 pm

IanB wrote:Bob does reduce the effective vertical resolution a bit but not by half and it does introduce interlace twitter (like a real CRT).
This is a very late reply, but as nobody else has done so it's probably appropriate to point out that the BBC-designed 'Weston' de-interlacer (a static spatio-temporal filter) is now out of patent protection. As its performance is far better than any other static de-interlacing filter, and superior to most adaptive/motion-compensated ones (which are typically far more complex), it makes little sense to use anything else.

The 'classic' Weston de-interlacer has a symmetrical 3-field temporal aperture, but if you can't afford a one-field delay a 2-field version (current and previous field only) is still pretty good. The simplest implementation has a 7-line vertical aperture, with the following coefficients (this is the filter used in the Genesis gmVLD8 line-doubler chip):

Code: Select all

          0.0625
-0.125              -0.125
          0.4375
 0.250               0.250
          0.4375
-0.125              -0.125
          0.0625
Note that the coefficients in the 'outer' fields sum to zero, which is key to its operation (it means that those fields contribute only high vertical frequencies to the output). The coefficients are also all multiples of 1/16 for ease of computation.

Richard.

User avatar
Richard Russell
Posts: 228
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

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

Post by Richard Russell » Sat May 12, 2018 10:33 pm

Richard Russell wrote:this is the filter used in the Genesis gmVLD8 line-doubler chip
For those nerdy enough to be interested in the spectra of de-interlacing filters (that'll be me, then!) here are two slices, at temporal frequencies of 0 Hz and 25 Hz, through the 2D spectrum of that Genesis filter. You can see how close it is to the ideal response (probably even closer than the filter in the patent), despite its simplicity:

Image

Budgie
Posts: 73
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 May 12, 2018 11:36 pm

hoglet wrote:
Budgie wrote: See below the test pattern (bottom only) after switch on and then after a calibration (i.e. pushing the button). Not sure why it doesn't calibrate on switch on ?
Is the second image after calibration? If so, then something is wrong as it has picked the worst possible sampling point!

Can you grab the debug log of the calibration?

There is a reason it doesn't currently calibrate on reset, but not a very good one. On my system I'm powering the Pi and CPLD from the +5V on the Beeb's RGB connector. I found that when you switch the Beeb on, the Pi actually boots before there is anything on the screen. The calibration doesn't work with a blank screen. I was intending to do an autocalibration after a few seconds, but haven't got around to implementing this yet.
Budgie wrote: Interestingly or not so interestingly I've just zapped my CPLD switching the beeb off of all things. I've only got RGB and SYNC connected not GND and 5V from the RGB connector. Not sure whether some suppression would be worth having on the PCB from the connector. May have been a one off as I do mess around a lot with this board.
You definitely need to have a GND connection from the Beeb's to the CPL board at all times. Omitting this probably what zapped the CPLD.

Dave
No the second image was before calibration. Doh on me not connecting ground, thanks for that. Now connected.

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

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

Post by tricky » Mon May 14, 2018 5:50 am

Does this project have enough debug info to help with a problem that I am having in this Scramble thread viewtopic.php?f=57&t=14988&p=203125#p203125?

User avatar
hoglet
Posts: 7121
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 » Mon May 14, 2018 6:43 am

tricky wrote:Does this project have enough debug info to help with a problem that I am having in this Scramble thread viewtopic.php?f=57&t=14988&p=203125#p203125?
See response in the New Scramble thread

noggin
Posts: 19
Joined: Mon Jul 17, 2017 3:06 pm
Contact:

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

Post by noggin » Mon Jun 04, 2018 12:29 am

Richard Russell wrote:
Fri May 11, 2018 5:48 pm
IanB wrote:Bob does reduce the effective vertical resolution a bit but not by half and it does introduce interlace twitter (like a real CRT).
This is a very late reply, but as nobody else has done so it's probably appropriate to point out that the BBC-designed 'Weston' de-interlacer (a static spatio-temporal filter) is now out of patent protection. As its performance is far better than any other static de-interlacing filter, and superior to most adaptive/motion-compensated ones (which are typically far more complex), it makes little sense to use anything else.

The 'classic' Weston de-interlacer has a symmetrical 3-field temporal aperture, but if you can't afford a one-field delay a 2-field version (current and previous field only) is still pretty good. The simplest implementation has a 7-line vertical aperture, with the following coefficients (this is the filter used in the Genesis gmVLD8 line-doubler chip):

Code: Select all

          0.0625
-0.125              -0.125
          0.4375
 0.250               0.250
          0.4375
-0.125              -0.125
          0.0625
Note that the coefficients in the 'outer' fields sum to zero, which is key to its operation (it means that those fields contribute only high vertical frequencies to the output). The coefficients are also all multiples of 1/16 for ease of computation.

Richard.
You beat me to suggesting a Weston deinterlacer - but I suspect the grunt required may put it out of reach?

User avatar
hoglet
Posts: 7121
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 » Mon Jun 04, 2018 6:33 am

noggin wrote:
Mon Jun 04, 2018 12:29 am
You beat me to suggesting a Weston deinterlacer - but I suspect the grunt required may put it out of reach?
I don't think there is any way we will be able to implement any kind of advanced deinterlacing in software on the ARM. There just isn't the spare time, or the spare memory bandwidth.

I think the only way to get deinterlacing of MODE 7 is if we can get the GPU to do it, which is clearly possible. Unfortunately, I can't find any documentation or examples about enabling this kind of video processing from bare-metal code.

Dave

noggin
Posts: 19
Joined: Mon Jul 17, 2017 3:06 pm
Contact:

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

Post by noggin » Mon Jun 04, 2018 12:22 pm

hoglet wrote:
Mon Jun 04, 2018 6:33 am
noggin wrote:
Mon Jun 04, 2018 12:29 am
You beat me to suggesting a Weston deinterlacer - but I suspect the grunt required may put it out of reach?
I don't think there is any way we will be able to implement any kind of advanced deinterlacing in software on the ARM. There just isn't the spare time, or the spare memory bandwidth.

I think the only way to get deinterlacing of MODE 7 is if we can get the GPU to do it, which is clearly possible. Unfortunately, I can't find any documentation or examples about enabling this kind of video processing from bare-metal code.

Dave
Might be worth dropping milhouse at the Pi Kodi forums a line - he implemented or worked on the current Kodi MMAL stuff (and fixed an error I spotted a couple of years ago)

They have moved where the deinterlacing happens on Pis ISTR to allow lower powered models to do MMAL Advanced on HD as well as SD content - and the MMAL Advanced is reasonably close to YADIF 2x. Personally - like Richard Russell - I think Weston deinterlacing is a nicer approach (as it doesn't require any motion adaption or compensation separate to the very ingenious V/T filter that it uses)

Any offline deinterlacing I do in ffmpeg I do with w3fdif (Weston 3-field) and it's now available in LAVFilters and/or MPC HC on PCs.

Personally I think it would be great if the Pi could implement Weston deinterlacing in Kodi - but that's way off topic for here ;)

User avatar
hoglet
Posts: 7121
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 » Mon Jun 04, 2018 9:44 pm

Hi Guys,

My third attempt at a PCB for this has been more successful - I've managed to reduce the form factor to the size of the Pi Zero:
rgbtohdmi1.png
rgbtohdmi2.png
rgbtohdmi3.png
The two upward pointing connectors are for debugging, and won't need to be fitted in the final system.

This is using 8mil tracks for signals, 15 mil tracks for power, and 8 mils spacing.

The KiCad design is in github:
https://github.com/hoglet67/RGBtoHDMI/t ... r/kicad/v3

I'll fiddle a bit more tomorrow (e.g. the silk screen), then send it off to Seeed.

Dave

dp11
Posts: 797
Joined: Sun Aug 12, 2012 8:47 pm
Contact:

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

Post by dp11 » Mon Jun 04, 2018 10:42 pm

An option would be to use the spare GPIO signals and TX RX Via Jumpers so that the CPLD can be insystem programmed

User avatar
BigEd
Posts: 1826
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 » Tue Jun 05, 2018 7:03 am

(Nearby, myelin noted
xc3sprog a small standalone bitstream pusher.)

User avatar
hoglet
Posts: 7121
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 » Tue Jun 05, 2018 1:09 pm

I've had a think about Dominic's suggestion (adding support for programming from the Pi).

I agree this would be a nice feature to have, but I'm inclined not to do add this for now, for a couple of reasons:
1. Trying to find space for 4 links plus the associated routing is painful
2. I don't really have four spare GPIOs (unless I use GPIO 0 and 1)
3. We would (I think) need a completely separate update image that was a proper OS

I'm close to a final design now I think.

I found one bit mistake this morning - for some reason I was using 16 mil vias, where as the min size that seeed deal with is 24 mil. Fixing that was very tedious!

Here's the latest renderings:
rgbtohdmi1.png
rgbtohdmi2.png
rgbtohdmi3.png
I've changed the CPLD pinout quite a bit, so I need to check there are no routing issues before sending this off.

Dave

User avatar
BigEd
Posts: 1826
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 » Tue Jun 05, 2018 3:54 pm

It certainly looks very nice and should prove to be a popular upgrade!

I should perhaps bring my Samsung LCD round one day to see if it works well - or, are you already highly confident of supporting just about any monitor?

Budgie
Posts: 73
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 » Wed Jun 06, 2018 9:24 pm

This is awesome Dave. Thanks for finally bringing this to life !!

User avatar
Elminster
Posts: 2032
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 » Wed Jun 06, 2018 9:51 pm

I would love to get rid of all those boxes, cables, converters etc.

I wonder if there is a way so squeeze inside a switch box, 4 computers in, some pi magic and 1 hdmi out.

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

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

Post by tricky » Thu Jun 07, 2018 6:02 am

I don't know if it might dirty the signals, but I would have thought an old parallel port switch would do. It might be a little big.

User avatar
danielj
Posts: 6174
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

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

Post by danielj » Thu Jun 07, 2018 7:00 am

Even a dedicated vga switch degrades video quite substantially...

User avatar
Elminster
Posts: 2032
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 » Thu Jun 07, 2018 8:23 am

Sad to say not all of us have enough room for 10 monitors.

Can't be more degrade that what i currently do.

Every thing goes into a scart switcher -> into a vga convertor -> into a network KVM -> across network -> displayed in java view on Mac.

Or plug directly into my little (CCTV) LCD that I have at ABUG South.

User avatar
danielj
Posts: 6174
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

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

Post by danielj » Thu Jun 07, 2018 8:37 am

Don't think I do either :D I use a kvm from my converter, but it does noticeably fuzz the display.

User avatar
Elminster
Posts: 2032
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 » Thu Jun 07, 2018 8:49 am

danielj wrote:
Thu Jun 07, 2018 8:37 am
Don't think I do either :D I use a kvm from my converter, but it does noticeably fuzz the display.
Mind you my Electron used to be plugged into a 10inch blank and white TV with a manual tuning knob when I was a youngster. So probably fuzzy is proper retro. :)

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

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

Post by tricky » Thu Jun 07, 2018 11:53 am

I hoped that it might work as the converter will clean up the signal colour, as long as the timing isn't affected too much.

User avatar
hoglet
Posts: 7121
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 » Wed Jun 13, 2018 12:36 pm

Here's the final board design that has just been sent off to Seeed:
rgb-to-hdmi1.png
rgb-to-hdmi2.png
rgb-to-hdmi3.png
Total cost for ~10 boards was $15.28, including postage.

Now for the 3-4 week wait.

Dave

User avatar
hoglet
Posts: 7121
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 » Wed Jun 13, 2018 12:45 pm

And the current prototype:
IMG_1323_small.JPG
Dave

john_A3000
Posts: 10
Joined: Tue Jun 12, 2018 4:24 pm

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

Post by john_A3000 » Wed Jun 13, 2018 1:32 pm

Really cool project.
But, I do find it a bit worrying that there seems to be a mad rush to HDMI everything retro.
I mean, that Spectrum ZX-HD, just makes the image look no different to a PC, connected to the same monitor, running Spectacular.
Acorn BBC Model B, 32k, Turbo MMC, 9-Pin Joystick adapter.
Acorn BBC Master 128k, IDE + 2Gb CF Card, Multi-OS selector.
Acorn Archimedes A3000, 25Mhz Arm3 upgrade, 4Mb, IDE + 2Gb SDCard, PS/2 Mouse.
Acorn AKF30 RGB Monitor.

User avatar
BigEd
Posts: 1826
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 » Wed Jun 13, 2018 2:22 pm

Mode 7 will always look retro!

User avatar
Elminster
Posts: 2032
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 » Wed Jun 13, 2018 3:32 pm

john_A3000 wrote:
Wed Jun 13, 2018 1:32 pm
Really cool project.
But, I do find it a bit worrying that there seems to be a mad rush to HDMI everything retro.
I mean, that Spectrum ZX-HD, just makes the image look no different to a PC, connected to the same monitor, running Spectacular.
Not sure it is a mad rush, just modern TV's are binning most connectors in favour of HDMI. And the scart to HDMI convertor boxes are reasonably expensive and bulky. You dont have to use one, but I myself have no retro monitors, and will never be allowed one. So I can see why people want them.

john_A3000
Posts: 10
Joined: Tue Jun 12, 2018 4:24 pm

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

Post by john_A3000 » Wed Jun 13, 2018 4:00 pm

HDMI will never look as good as a CRT. These machines were not designed with HD in mind, so will look awful when stretched on a big HDTV.
Acorn BBC Model B, 32k, Turbo MMC, 9-Pin Joystick adapter.
Acorn BBC Master 128k, IDE + 2Gb CF Card, Multi-OS selector.
Acorn Archimedes A3000, 25Mhz Arm3 upgrade, 4Mb, IDE + 2Gb SDCard, PS/2 Mouse.
Acorn AKF30 RGB Monitor.

User avatar
hoglet
Posts: 7121
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 » Wed Jun 13, 2018 4:26 pm

john_A3000 wrote:
Wed Jun 13, 2018 4:00 pm
HDMI will never look as good as a CRT. These machines were not designed with HD in mind, so will look awful when stretched on a big HDTV.
There's not really any stretching going on, it uses the correct margins so the 4:3 aspect ratio is preserved.

There are some screen shots earlier in the thread:
viewtopic.php?p=192309#p192309

Dave

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

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

Post by tricky » Wed Jun 13, 2018 4:31 pm

He might mean big pixels.
Having the option is good and we might be able to sneak a feature or two in when Hoglet isn't looking.
I'll still be filling the back seat of my car with CRTs when going to a show though ;)

Post Reply