Discovering if a mode is in the MDF
Sprow (202) 1158 posts |
I’m looking at an application that was intended to use a numbered mode (mode 13 which is 320×256) which looks fine on the Risc PC, but attempting that on the Pi gives some weird result where there’s a vertical split but overall the image fills the screen, and on a Beagleboard the (same) monitor gives a weird slurred horizontal blinds effect. If I load a (slightly wrong, eg. AKF85) MDF for a different monitor, the Pi is happy but the Beagleboard is still weird, but maybe the OMAP video isn’t really happy that low res. In principle with a little work everything could be scaled to use 640×512, but I’d rather not just double up all the pixels when the monitor clearly knows what to so, especially for speed reasons. I tried calling OS_CheckModeValid but on all 3 platforms it returns carry clear saying the mode is valid. Rummaging in the kernel I see FindOKMode will try Service_ModeExtension, but the only claimant for that is the ScreenModes module which has an upfront check to not bother with numbered modes. When not claimed the kernel looks through its BigVIDCTable and of course locates mode 13 and that it’s OK on an SVGA-like monitor, then returns. On the face of it it looks like the GraphicsV owner doesn’t get an opportunity to reject numbered modes. So here’s the question(s): a) shouldn’t numbered modes be passed through the GraphicsV vet mode? |
Rick Murray (539) 13850 posts |
Just out of interest, if you ask for the mode dimensions for mode 13, what does it return? The expected for the mode, or the “this ought to fit” closest match with whatever is in the MDF? |
Jeffrey Lee (213) 6048 posts |
Mode vetting and translation is a tangled mess. The bit you’ve missed (or at least one of the bits) is that OfferModeExtension actually calls Service_ModeExtension up to three times:
For the 2nd & 3rd calls ScreenModes will do its stuff, including making the appropriate GraphicsV calls to make sure the driver is happy with whatever mode it’s thinking of replying to the OS with.
Actually, by my reading, (assuming you’ve got monitor type 7 set) it’ll check BigVIDCTable, fail to find anything, check SubstModeTable, fail to find anything, issue Service_ModeTranslation, and then ScreenModes will jump in and spin its wheel of fortune to try and find a VGA-ish mode which it has a definition for (most likely 640×480). If ScreenModes fails then the kernel will go into its SVGA fallback mode and try picking a substitute mode from 25-28 (complete with some funny logic to try mode 0? FindSubstitute will get called with R10=original mode, which will then call PushModeInfoAnyMonitor with r10=original, r11=0, which will then call OfferModeExtension, which we know will fail, so will then cause it to check BigVIDCTable for monitor type 7 and the substitute mode (0), which will fail, which will then cause it to go into a last-minute panic and use monitor type 0 mode 0. Then FindSubstitute will check the BPP of the pushed mode (i.e. 1bpp), and ultimately ends up returning with either mode 25 or mode 28 depending on whether the driver likes 1bpp modes or not) After all that, OS_CheckModeValid will then call OfferModeExtension again (by way of PushModeInfo), so if the above logic ended up picking something which isn’t supported then OfferModeExtension will fail and OS_CheckModeValid will return with carry set to indicate it’s a bad mode. There’s also some equally crazy logic which goes on when you try and select a mode and the kernel has trouble finding out which one to use – typically resulting in one of modes 25-28 being used if you ask for a numbered mode which isn’t in the MDF.
Negative. The mode is within the hardware limits, it’s more likely to be the monitor that doesn’t like the mode rather than the OMAP. |
Sprow (202) 1158 posts |
Very tangled it seems, I did only read through it once not thrice. The problem is that doesn’t seem to match the empirical test I did on the Pi. First I loaded “Iiyama Vision Master 1451” (not actually my monitor, but it’s on the standard disc image) then *BASIC So the mode seems to get substituted, but when asked the mode is believed valid, hence my initial head scratching and topic of this thread. c) should OMAP video reject mode 13? In each case it’s the same monitor being used, with the same MDF as in the working case. With Risc PC it’s fine (via analogue in), with Pi (via HDMI) it’s just dodgy OS_CheckModeValid, with OMAP the picture is weird as mentioned. I’d look at the syncs, except it’s not analogue so I’m not going to see much on a scope.
The X size was 319 (via OS_ReadModeVariable) so it seemed to know about the mode. |
Jeffrey Lee (213) 6048 posts |
Hmm, interesting. How old is your ROM? I’ve just repeated your test with one from the 27th and mode 13 worked fine after loading the Vision Master MDF.
Remember that with the Pi we aren’t actually in control of the mode timings; instead the GPU just scales whatever we give it to whatever output resolution it picks on startup. I’ve just done some experimentation myself, and discovered the following:
So although I can’t prove that 320×256 works, I am fairly confident that the OMAP is generating the correct signals, judging by the OSD information from the first monitor. And I’m also fairly certain that just because a monitor “works” with a given signal over VGA, it doesn’t mean the same signal will work correctly over DVI/HDMI. But I guess the only way to prove these things for certain would be for someone with a HDMI/DVI-D to VGA adapter to confirm that the modes work correctly! |
Sprow (202) 1158 posts |
Thanks for looking into this in such detail.The problem is that doesn’t seem to match the empirical test I did on the Pi. Now this morning it’s not doing it any more having changed nothing, so I’ll have to keep an eye out for it. Maybe it’s the order I was testing it in, but in general after a power cycle it’s OK? Dunno. Aside: the Pi ROM was from 08-Apr-2014 and I’ve now tried 01-May-2014 too.
Back to the Beagleboard: On my Hyundai monitor the OSD says 320×256 31.4kHz/70.1Hz but the display is weird banding in columns and horizontal stripes with a net slant. I suppose it might be trying to auto scale it, and maybe it doesn’t try to autoscale the VGA port? I dug out a Viewsonic monitor and its HDMI input OSD says 720×400 31.5kHz/70.1Hz 28.2MHz pixel clock but it’s not locked horizontally (shaking left/right quite badly). I seem to have lost the lead that fits the plug on the telly – will buy another and try that later. It seems for now OS_CheckModeValid might be behaving as I want, so I’ll add a call to that to the application, and will try to be a bit more methodical with the Pi testing. Beagleboard still has a question mark over it for now. |
Chris Evans (457) 1614 posts |
Both of you know vastly more than I’ll ever know about RISC OS so I hesitate to mention it. In the past I’ve had systems that worked fine with a configured MODE 28 but not with WIMPMODE 28 which seemingly was the same. |
Sprow (202) 1158 posts |
Got a replacement HDMI cable, but the (Sanyo) TV wouldn’t do 320×256 either. That makes 0% digital success from the Beagleboard on 3 monitors. I’ll see if there’s anything else I can deduce without buying any more monitors.
That might be that the configured mode uses a table of timings in the kernel during early initialisation, by the time you need a wimpmode you’ve loaded a (possibly wrong timing) MDF. |
Steve Revill (20) 1361 posts |
Just throwing this out there – it’s probably not relevant but useful to other readers who stumble across this thread – don’t hotplug DVI/HDMI on a BeagleBoard, unless you want to kill it! |
Frederick Bambrough (1372) 837 posts |
Yes, the manual is quite specific about that. HDMI before power connection. |
Sprow (202) 1158 posts |
I splashed out on just such an adapter, having prised it open it’s based on a EP94Z1E which from the block diagram (and the size of the chip) doesn’t look to contain a framestore of any sort so should pass everything through faithfully. The first hurdle was it’s quite thirsty: approx 250mA, and that was enough to trip the PTC resistor (RT1) on the Beagleboard xM. As I’m powering from a bench power supply I just selected a more appropriately sized nail for the job. To its credit, it passes through the EDID data, so I was able to read the monitor personality via the HDMI to VGA adapter from RISC OS. Looking on the scope, the H+V sync timings were spot on compared with the AKF85 MDF I selected, and behold – an image was formed at 320×256! However, the image kept blanking during periods of high activity, while an idling desktop (320×256, quite lo res) was solid/stable. During busy sprite plotting the screen blanked for exactly 35 vertical syncs (0.5s), I tried *AUDIO OFF just incase the sound DMA was in a bad mood but that didn’t help, and looking on the scope the syncs remained rock solid it’s definitely the R/G/B image that is set black. So this leads me to wonder |
Jeffrey Lee (213) 6048 posts |
Hmm. 320×256×70Hz isn’t exactly “high bandwidth”, but I guess it’s possible that either the low resolution or low clock rate is causing it some difficulty filling the DMA FIFO in time for the frame to start. If you’re lucky a debug build of OMAPVideo will tell you what’s going on. But the fact you say that the syncs remain solid suggests that it isn’t hitting the DISPC_IRQ_SYNCLOST handler, because that will briefly stop video output completely in order to reset the controller. Unless your scope wasn’t picking that up, of course! |
Sprow (202) 1158 posts |
I’d dialled up the capture memory to 10Mpts so I had ~1s on screen to scroll through – it was definitely something blanking the image while the syncs continued. Having borrowed another HDMI to VGA adapter that didn’t show any image at all, but I shalln’t break that one open as it’s not mine. I added some counters into the OMAPVideo module in the sync lost and sync lost digital handers, and the GraphicsV set blank entry point (which is what the kernel calls if anyone uses OS_UpdateMEMC to halt video DMA), but zero calls to any of those despite seeing picture blanking a number of times. Then I looked at the schematic and it appears the TFP410 has been wired up to use DK[3:1] pins to set the skew between clock and data from the OMAP3530. However, none of the resistors are fitted so the default is 0-0-0. If I fit R95 the blanking problem goes away. So it would seem to be a quirk of the BBxM, either the extra screen activity is causing crosstalk that causes the TFP410 to see transitions on the floating DK pins (they have weak pull downs) or such a low pixel clock has much more skew than all the other modes and it’s a bit on edge. Having looked, clock and data are lined up to within 1ns. The following quality test program didn’t show any blanking MODE 13 so now I’m just confused what’s special about the plotting I’m doing? Workaround: If I just make MODE 13 be 15MHz pixel clock by editing the MDF (and adjust the front/back porches to soak up the spare time) it stops blanking, so in conclusion I’m pointing the finger at TFP410 and minimum clock rate supported. |
Jeffrey Lee (213) 6048 posts |
Sounds like a reasonable conclusion. Unless you have any other ideas, I’ll update OMAPVideo to enforce a minimum 15MHz clock rate. |
Sprow (202) 1158 posts |
Workaround: If I just make MODE 13 be 15MHz pixel clock I went in steps of 100kHz and the image stopped blanking at 14800 but had a couple of ‘scratchy’ horizontal lines, 14900 was stable but had a few scintillating pixels, 15000 was all good. As the datasheet says 25MHz is the minimum I think 15MHz as a lower limit is a reasonable amount of slack for DVI output, and maybe 13.5MHz for the TV out? |
Jeffrey Lee (213) 6048 posts |
TV out isn’t really relevant at this point; it currently just uses hard-coded PAL or NTSC signal timings. Maybe one day I’ll get round to working out how to program it properly! |