raspberrypi / firmware

This repository contains pre-compiled binaries of the current Raspberry Pi kernel and modules, userspace libraries, and bootloader/GPU firmware.
5.19k stars 1.68k forks source link

Support for progressive PAL60 in config.txt/sdtv_mode #811

Open manekinekodesu opened 7 years ago

manekinekodesu commented 7 years ago

I use my Raspberry Pi 3 to emulate consoles. And my crt tv only supports PAL/PAL60 modes. Most games were not/badly optimized for PAL 50 Hz mode. And PAL60 can be used to play NTSC content full screen and full speed, as it was meant to be played.

popcornmix commented 7 years ago

So with your display do you get no picture when using NTSC output?

I'm not an expert on composite TV out and I'm certain if the hardware can handle this. Do you know exactly what the TV wants for PAL60? Is this the NTSC resolution and framerate, but with the PAL colour carrier frequency?

deborah-c commented 7 years ago

Wikipedia's actually a pretty good resource for this: https://en.wikipedia.org/wiki/PAL

manekinekodesu commented 7 years ago

I get black and white picture, both with NTSC and Brazilian PAL-M.

Yes, PAL60 has NTSC resolution and framerate, but with the PAL colour carrier frequency. As @deborah-c has said, Wikipedia's all the specs: https://en.wikipedia.org/wiki/PAL#Multisystem_PAL_support_and_.22PAL_60.22

A "PAL 60" signal is similar to an NTSC (525/30) signal, but with the usual PAL chrominance subcarrier at 4.43 MHz (instead of 3.58 as with NTSC and South American PAL variants) and with the PAL-specific phase alternation of the red colour difference signal between the lines.

popcornmix commented 7 years ago

Yes, I was using wikipedia. The "PAL-specific phase alternation of the red colour difference signal between the lines" is the part that I'm unsure of. Nothing in the peripheral spec sounds like that so it is possible it can't be independently changed.

deborah-c commented 7 years ago

That's more or less the definition of PAL (Phase Alternating Lines) -- the R-Y chrominance signal alternates phase between lines. If there's an NTSC/PAL switch, it should cover this, I think.

popcornmix commented 7 years ago

@manekinekodesu could you give this firmware a test: https://drive.google.com/uc?id=0B-6zmEDJwxZEU3V2RkxMTzktS3M&export=download By default no change, but: sdtv_mode=0x22 should give PAL 60 sdtv_mode=0x20 should give NTSC 50

Basically for PAL 60 I'm using normal PAL settings, but have changed resolution/framerate to NTSC. Not sure if that is correct, but my composite TV does show a picture (with colour) in the new modes.

manekinekodesu commented 7 years ago

Tested this on 2 pal crts(one of them supports ntsc signal over composite in but colors look off quite a bit). Results are: sdtv_mode=0x22 - 60Hz, fullscreen, no color (on my second tv I can see that colors actually in NTSC format) sdtv_mode=0x20 - 50Hz letterbox, PAL colors (just like the usual PAL)

popcornmix commented 7 years ago

How can you tell colours are NTSC format?

Any different with https://drive.google.com/uc?id=0B-6zmEDJwxZEVmhhWjNOZGRPWHc&export=download ?

manekinekodesu commented 7 years ago

I can tell it by the way my second TV displays NTSC colors - they are off (the green is almost blue etc)

Results from the second firmware are closer: sdtv_mode=0x22 60 Hz check, fullscreen check, PAL color check, but there is a problem: image is statically skewed: img_20170523_182943

sdtv_mode=0x20 looks like 50 Hz, monochrome, picture is also skewed, albeit in another direction: img_20170523_183451

popcornmix commented 7 years ago

Can you try: https://drive.google.com/uc?id=0B-6zmEDJwxZENTd3bWZsMktLME0&export=download

I notice that PAL has a horizontal front porch of 20 and NTSC has 14. Those 6 pixels seem to match the slope you are seeing.

manekinekodesu commented 7 years ago

Yes, that fixed it. Now the picture looks totally PAL60 to me! 60 Hz, fullscreen and PAL colors! img_20170524_103450 Could progressive scan be enabled for this mode as well?

And NTSC50: img_20170524_095544 I guess this TV has not been designed with NTSC50 in mind.

popcornmix commented 7 years ago

Great. I'm not sure how defined NTSC 50 is, so it's hard to say if the TV doesn't support it or we are generating the wrong thing. If anyone has a source that generates NTSC 50 correctly and a TV that displays it we could be more sure.

I've tried progressive in addition to PAL 60 and get a rolling display - is that what you see? I can't think of anything obvious that causes this and adjusting the vertical front/back porch doesn't seem to help.

manekinekodesu commented 7 years ago

@popcornmix How do I try progressive in addition to PAL 60?

In sdtv_mode=18 I get PAL 50 and rolling display (slowly rolls downward)

In sdtv_mode=0x20 NTSC 50 picture is static and has vertical offset (see photo above). It's not rolling

popcornmix commented 7 years ago

You add 0x10 for progressive and 0x20 for "alt mode" (i.e. flip PAL/NTSC resolution/framerate). So: sdtv_mode=0x30 for progressive NTSC 50 sdtv_mode=0x32 for progressive PAL 60 I don't think they will work (they don't for me) but I'd be interested if you see the same as me.

manekinekodesu commented 7 years ago

Ok, I've connected my rpi 3 to TV tuner card and recorded some test videos, hope they will be of some help to you: I've set sdtv_mode=0x32 for progressive PAL 60 On my tv capture card I've set "video standard = PAL 60" and "vertical synchronization = Normal tracking/Fast tracking": beholdtv-2017-05-25-18-16-57-43

Then I've set "vertical synchronization = Free running mode (disable tracking)": beholdtv-2017-05-25-18-12-43-10

So this display rolling has to do something with vertical sync. I could not find Pal 60 modeline, but here is a bunch of other useful modelines http://www.geocities.ws/podernixie/htpc/modes-en.html. I don't know if they are of any help though.

What's interesting, in your second firmware, normal progressive modes 0x10-0x12 are also broken: beholdtv-2017-05-25-18-36-25-69 Should they be that way?

On my crt tv 0x32 mode looks like this: beholdtv-2017-05-25-18-16-57-43

popcornmix commented 7 years ago

Yes, I think I spotted the "slow roll" issue with progressive mode and fixed it. Try: https://drive.google.com/uc?id=0B-6zmEDJwxZEWW5HT0hSaFNxb0E&export=download

manekinekodesu commented 7 years ago

Yep, modes 0x10-0x12 are fixed.

Spotted something weird in the 0x22 mode: beholdtv-2017-05-25-22-47-49-67

I've also hooked up my pal60 modded sega mega drive 2 to the tv tuner card and there were no such artifacts.

manekinekodesu commented 7 years ago

I've tried to use 0x22 mode recently and noticed that it runs a bit slower 59.5 (causing sound crackling ) instead of 60.00 like 0x00 mode. Then I've tried 0x20 mode which runs faster than 0x02 mode, 50.35 instead of 50.00 and it's also offset from the top a little so the bottom gets cut and warped to the top.

Maybe something else needs to be swapped, like sync pulse width for example. The 0x22 mode can be sped up to 59.94 - 60.00 by decreasing sync pulse width and horizontal front & back porches or maybe increasing dot clock frequency. @popcornmix You've said that you are able to manually adjust vertical porches. So, is it possible to tweak other values, as I've suggested above? Maybe it will help to rid of the rolling in progressive modes.

Also:

The symptom of a misplaced sync pulse is that the image is displaced on the screen, with one border excessively wide and the other side of the image wrapped around the screen edge, producing a white edge line and a band of "ghost image" on that side. A way-out-of-place vertical sync pulse can actually cause the image to roll like a TV with a mis-adjusted vertical hold (in fact, it's the same phenomenon at work). Black Magic and Sync Pulses

c0ommandc0m commented 7 years ago

Hi @popcornmix , @manekinekodesu . I just got into this thread looking also for PAL 60hz.

Amazing work you're doing here!!!

Really, really needed to get things running smoothly on a SD TV here in PAL areas...

Got the latest firmware and tried 0x22. And as @manekinekodesu posted, all good but some flashing on some aras of the screen, depending on the intensity and contrast of colors. Could it be just luminance is being updated oddly?

With 0x32 got the same lack of V sync. Both modes (PAL 60 480i / 240p) would be such a great addition. Actually, on the Gamecube & Dreamcast era it was quite common to get games that asked you if your monitor supported PAL 60 and, in case they did, they'd do the switch in order to run 'as intended'.

Tested all on my Sony KX14CP1 CRT, - a very good one I must say - That accepts both PAL and true NTSC signals.

If there's anything I can test or help you in any other way, please let me know!

JamesH65 commented 6 years ago

@popcornmix Taken a quick look at the code but difficult to tell what has been changed and/or added to master branch related to this issue Any status update on this?

Sobakin76 commented 6 years ago

@popcornmix I have a good 15" composite monitor JVC TM-H150C and RPi3b, with firmware downloaded from this thread posted May 25 it works in PAL60 mode but only in mode 0x22 (interlaced) and flickers alot, but in mode 0x32 (progressive) gets out of sync. Monitor's OSD says "PAL", tvservice -s says PAL 60Hz and NTSC (720x480) resolution and picture size and proportions are the same as NTSC original mode. This mode is quite better than original NTSC because a much less color artifacts but more compatible for retrogaming than standard PAL 50Hz (in cga/ega games used color dithering in NTSC modes monitor shows gradient colors but OK in PAL50 and PAL60Hz, but in PAL50 too much spacing in top and bottom and flickering as it's only 50Hz). Also at PAL_M modes with this firmware it shows currupted picture, with original latest firmware it shows correct in luma but rainbow colors and monitor recognized it as NTSC. I would appreciate if You add support of PAL60 progressive. I'm ready to test anything You need for it.

pietch commented 6 years ago

I'm trying to set CVBS output to PAL-N (south america): 625 lines, 576 active lines, 50Hz, 3.58205625 MHz color carrier. I can't find any documentation. Is this combination supported by RPi hardware?

popcornmix commented 6 years ago

@pietch no, PAL-N is not supported.

shaum257 commented 6 years ago

@popcornmix I am using a Raspberry Pi 3B+ and I have a PAL crt television. I tried your firmware zip file and set the sdtv_mode=0x22. After applying all that, when I power my Pi on, I see a rainbow screen(which is normal), but also a thunderbolt icon, telling me that it's not receiving enough power and therefore it stays on that screen and I'm unable to get into emulationstation. Luckily I made a backup of my firmware files so I could go back, then managed to get into emulationstation. But I want to have PAL60 and not PAL50. Your firmware files aren't compatible with my Rapberry Pi 3B+. So is there any way to get PAL60 on a Pi 3B+? I would appreciate your help!!! Oh and I'm using the official Raspberry Pi power supply --> 5.1V 2.5A

elfoam commented 6 years ago

I'm in the same situation as Shaum257, I have a CRT which will run 60hz but can't display the NTSC colours, I would be very happy if the PAL 60hz modes could be added to the PI3b+. That would make that TV very useful when right now I can't use it for much at all... Well of course I could buy a 3b.. but I have the 3b+

alessioscand commented 6 years ago

@popcornmix excuse me if I write here but issue #683 is closed, and maybe this is somehow related.

In sdtv_mode=16 (composite out) retrogames with a resolution of 320x240 (or 320x224) are blurry: ok, that's probably because, I suppose, RPi is outputting 720x480. But if I set same games to a multiple integer resolution of 640x480 (or 640x448) I get a sharper image but also a lot (really a lot) of "rainbow effect".

It seems that this does not happen in PAL mode, is this normal? thank you!

elfoam commented 6 years ago

I'm not sure this thread is still being bumped? in any case I'm still very interested in PAL 60 video modes :) on the 3b+ :). @Antiriad PAL always has less colour distortion compared to NTSC over composite, that is normal. Is it possible to somehow run the PAL colour system at 60hz 240p? that would be amazing :)

shaum257 commented 6 years ago

@elfoam I'm also still very interested in PAL 60 video modes on my Raspberry Pi 3B+. I've commented like 2 months ago and I'm still waiting for a satisfying answer. If only @popcornmix could reply and put a download link for the working firmware files for the RPi 3B+, I would really appreciate if he does that. But yeah I'll be still keeping check for this issue #811. Hopefully our saviour @popcornmix will reply and put a download link for the firmware files soon. If that day ever comes, then I'll be surely partying hard after!!! lol

pelwell commented 6 years ago

If this was easy it would have been done already. popcornmix has already put quite a bit of time into this issue, along with various other PAL and NTSC variations, but we are restricted by the modes provided by the VEC block.

elfoam commented 6 years ago

It seems like the firmware he made for the 3b does everything I want anyway, although I'm not sure the 288p pal 60 was ever 100%? I'll buy a 3b and try it anyway if the 3b+ isn't ever getting this. Like a lot of people I'm done with LCDs and going back to CRTs only

pelwell commented 6 years ago

If it is simply a case of adding some simple changes that have been shown to work to the mainline builds, and if those changes aren't at the expense of other functionality, then I'd say you have a chance. But this is a relatively niche area and it has to compete for time with lots of other work, so don't hold your breath.

alessioscand commented 6 years ago

@elfoam progressive PAL-60 is perfectly working on my RPi 3. Video quality is outstanding, compared to progressive NTSC with a lot of rainbow banding. Unfortunately in PAL-60 I can't get a full screen viewport in Retroarch for NTSC games, so I really hope that what you wrote (PAL coloring method in NTSC progressive video mode) is doable. I hope that @popcornmix will read this. ;)

elfoam commented 6 years ago

I know PAL colours with 60hz on NTSC resolution is against all standards etc but it would be perfection for composite inputs and old CRTs. It could be just mode... Awesome rather than any standard lol

Sobakin76 commented 6 years ago

@elfoam progressive PAL-60 is perfectly working on my RPi 3. Video quality is outstanding, compared to progressive NTSC with a lot of rainbow banding.

Which settings do You use to turn PAL60 progressive mode? And which firmware? I tried old experimental firmware and in PAL60 worked only interlaced mode and it was flickering.

elfoam commented 6 years ago

Yeah @Antiriad are you using the firmware posted here or are you on the standard current 3b firmware?. I have a TV that I think I should be able to adjust to make the screen look ok

alessioscand commented 6 years ago

@Sobakin76 @elfoam I'm using latest stable release of LAKKA (www.lakka.tv) and so the firmware packed with it. No issues at all with PAL-60: picture is stable and colors are perfect, no rainbow banding at all (sdtv_mode=0x32). Unfortunately it's nearly impossibile to get a viewport for NTSC games that is in fullscreen and without non-integer scaling artifacts.

Sobakin76 commented 6 years ago

@Sobakin76 @elfoam I'm using latest stable release of LAKKA (www.lakka.tv) and so the firmware packed with it. No issues at all with PAL-60: picture is stable and colors are perfect, no rainbow banding at all (sdtv_mode=0x32).

Are You sure it's output is really PAL60? My Raspbian in mode 0x32 runs really in progressive PAL50 (the same as in 0x12), just scaling 240p output to 288 (if "framebuffer_height=240")

alessioscand commented 6 years ago

@Sobakin76 well I just read this comment of @popcornmix and I really didn't notice speed differences (50hz/60hz) with sdtv_mode=18:

You add 0x10 for progressive and 0x20 for "alt mode" (i.e. flip PAL/NTSC resolution/framerate). So: sdtv_mode=0x30 for progressive NTSC 50 sdtv_mode=0x32 for progressive PAL 60 I don't think they will work (they don't for me) but I'd be interested if you see the same as me.

I'll check again ASAP.

elfoam commented 6 years ago

Just check is the scrolling is smooth in Strider or Sonic the hedgehog and you'll soon see if it's 50 hz or 60hz

elfoam commented 6 years ago

@Antiriad @Sobakin76 I just tested sdtv_mode=19 on my 3b+ and it's 60hz for sure, all the colours are rainbowed but otherwise that seems to have potential. Maybe the rainbow is just because my TV wont do the Brazilian colours?.. I'll try on my trinitron. sdtv_mode=0x22 is 50hz standard interlaced PAL. sdtv_mode=0x32 is also 50hz but 240p so neither of those are working / do what they are supposed to. If I had good colours rather than rainbows on sdtv_mode=19 would be winning though.

elfoam commented 6 years ago

I get the same rainbow colours on the brazilian modes on one of my LCD tvs. I'll keep trying other sets.

elfoam commented 6 years ago

Ok on the Trinitron where I can switch between PAL/NTSC 3.58 and NTSC 4.43, it's NTSC 3.58 that gives the rainbow colours. PAL and 4.43 are black and white in those modes (3 and 19). This is still all on the 3b+. Mode 19 is 60hz but I don't know if it's working on Brazilian sets as far as colour goes. Both standard PAL 60 modes though are broken for sure on the 3b+, they are both 50hz. I still think we only need one mode=awesome that is standard pal colours on 60hz 240p. That would be the best pi update of all time if that's even possible.

Sobakin76 commented 6 years ago

@Antiriad @Sobakin76 I just tested sdtv_mode=19 on my 3b+ and it's 60hz for sure, all the colours are rainbowed but otherwise that seems to have potential. Maybe the rainbow is just because my TV wont do the Brazilian colours?.. I'll try on my trinitron. sdtv_mode=0x22 is 50hz standard interlaced PAL. sdtv_mode=0x32 is also 50hz but 240p so neither of those are working / do what they are supposed to. If I had good colours rather than rainbows on sdtv_mode=19 would be winning though.

50hz can't be 240p, it's 288p or 576i (@ standard 15.7kHz) type "tvservice -s" and You'll see standard PAL 720x576 @ 50Hz instead of 720x480 @ 60Hz for NTSC, PAL60 or PAL-M.

JamesH65 commented 5 years ago

I'm a bit confused as to the state of this issue, have all the questions been answered?

elfoam commented 5 years ago

I'm a bit confused as to the state of this issue, have all the questions been answered?

@JamesH65 nah.. the video code in the PI is broken. I've moved to using the Nintendo Wii for my emulation for now

JamesH65 commented 5 years ago

This issue will be closed within 30 days unless further interactions are posted. If you wish this issue to remain open, please add a comment. A closed issue may be reopened if requested.

AlistairThom commented 5 years ago

I would also really appreciate the holy grail of PAL60p support in the 3b+ firmware which @elfoam describes.

I'd be happy to test experimental firmware, contribute to a bug bounty, or help in any other way a non-video hardware coder can.

Thank you to @JamesH65 @popcornmix for the work they have done on this, getting to where we are already. Maybe I'm naive/optimistic, but it feels like we are tantalisingly close.

Sobakin76 commented 5 years ago

I lost all hopes here and moved to VGA666 120Hz 240p on 17" CRT VGA monitor (which I found much better image quality than composite because its true RGB and with no flicker, and its absolutely cheap solution now), but still interesting in PAL60 and/or PAL-M support in RPi firmware. I still own two composite 15kHz CRT monitors one of it 100% support PAL-M and other PAL60, and I ready to participate in testing if needed.

AlistairThom commented 5 years ago

I lost all hopes here and moved to VGA666 120Hz 240p on 17" CRT VGA monitor (which I found much better image quality than composite because its true RGB and with no flicker, and its absolutely cheap solution now), but still interesting in PAL60 and/or PAL-M support in RPi firmware. I still own two composite 15kHz CRT monitors one of it 100% support PAL-M and other PAL60, and I ready to participate in testing if needed.

Unfortunately, using a solution which utilises GPIO pins to generate video isn't viable for me, and I suspect many other retro gamers in the target audience for PAL60/PAL-M, who already use GPIO pins for arcade/console controller setups.

The prevalence of affordable/free CRT TVs ready to be given new life, makes PAL60/PAL-M from the composite port a desirable option for people searching for a cheap and straightforward entry-point to the glorious nostalgia of CRT gaming.

shaum257 commented 5 years ago

I still hope that @popcornmix releases a firmware for Raspberry Pi 3B+ for PAL60. So far I've gotten used to games running in 50HZ but the smoothness of 60HZ would be the definitive way to play retro games on a Pi 3B+. I mean if @popcornmix managed to release a firmware for the Pi 3B, then there shouldn't be any problem for him to release a firmware for the Pi 3B+ for PAL60. But yeah it's still up to @popcornmix if he feels like releasing it.