On Mon, Jan 06, 2003 at 02:56:26PM -0500,
[EMAIL PROTECTED] wrote:
> I hope the subject line was descriptive enough.
>
> I got a G400 Marvel for Xmas, thanks to my brother. :-) With this
> card, I can hardware capture field-correct MJPEG, which I can then
> transcode into MPEG2, all using the wonderful tools of the mjpeg-tools
> project.
>
> Why do you all care? :-)
>
> Well, for those of you following my G400 CRTC2 stuttering saga (hi
> Ville!)
:)
> What seems to be happening is that the interlacing parity of the display
> seems to be fading in and out. That is, at some point the order of
> the odd/even lines is correct, and then it's not and then it is, and
> then it's not and so on and so on.
This problem is hard to solve with CRTC2 since there is no way to contol
which field is displayed and when. The best thing I can think of is trying
to guarantee that after flipping we always display the same field. We sort
of tried that by calling GetCurrentOuputField() before the Flip() but that
approach has problems because we end up calling dfb_gfxcard_sync() in
between and we also check that we have enough time to write all of the
addrss registers. So there is a large variable involved here.
I've attached an experimental patch which tries to solve this problem in
the driver.
When Flip() is called we do this:
1. Call dfb_gfxcard_sync() since we really don't want this messing up
our delicate timing.
2. Check if we have enough time to write the registers, if not wait for
the next vblank.
3. Check the field and if it's wrong wait for the next vblank.
Now if we wait in step 2, step 3 can't really get the field wrong provided
that there isn't some huge latency spike involded. And if we don't wait
in step 2 there shouldn't be any problems provided the test for enough
time is good. (I'm not at all sure it is :)
Obviosly this behaviour isn't always wanted. I added it so that when
DLOP_DEINTERLACING is set in the layer options step 3 is executed. I also
added a SetField() call so that the user can decide which field should be
the first after a flip.
To use it set DLOP_DEINTERLACING in the layer options and call SetField(0)
or SetField(1) depending on which field you want to be the first. Now, I
have no idea if this really works so please test it and report back.
--
Ville Syrj�l�
[EMAIL PROTECTED]
http://www.sci.fi/~syrjala/
Index: DirectFB/gfxdrivers/matrox/matrox_crtc2.c
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox_crtc2.c,v
retrieving revision 1.9
diff -u -d -r1.9 matrox_crtc2.c
--- DirectFB/gfxdrivers/matrox/matrox_crtc2.c 27 Dec 2002 17:50:08 -0000 1.9
+++ DirectFB/gfxdrivers/matrox/matrox_crtc2.c 6 Jan 2003 21:05:27 -0000
@@ -57,6 +57,7 @@
DFBDisplayLayerConfig config;
DFBColorAdjustment adj;
int enabled;
+ int field;
/* Stored registers */
struct {
@@ -369,6 +370,19 @@
return DFB_OK;
}
+static DFBResult
+crtc2SetField( DisplayLayer *layer,
+ void *driver_data,
+ void *layer_data,
+ int field )
+{
+ MatroxCrtc2LayerData *mcrtc2 = (MatroxCrtc2LayerData*) layer_data;
+
+ mcrtc2->field = field ? 1 : 0;
+
+ return DFB_OK;
+}
+
DisplayLayerFuncs matroxCrtc2Funcs = {
LayerDataSize: crtc2LayerDataSize,
InitLayer: crtc2InitLayer,
@@ -380,7 +394,8 @@
SetColorAdjustment: crtc2SetColorAdjustment,
SetOpacity: crtc2SetOpacity,
GetCurrentOutputField: crtc2GetCurrentOutputField,
- WaitVSync: crtc2WaitVSync
+ WaitVSync: crtc2WaitVSync,
+ SetField: crtc2SetField
};
/* internal */
@@ -568,6 +583,10 @@
if (line + 6 > vdisplay && line < vdisplay)
while ((mga_in32( mmio, C2VCOUNT ) & 0x00000FFF) != vdisplay)
;
+
+ if (mcrtc2->config.options & DLOP_DEINTERLACING)
+ if (((mga_in32( mmio, C2VCOUNT ) >> 24) & 0x1) == mcrtc2->field)
+ crtc2_wait_vsync( mdrv );
mga_out32( mmio, mcrtc2->regs.c2STARTADD1, C2STARTADD1 );
mga_out32( mmio, mcrtc2->regs.c2STARTADD0, C2STARTADD0 );