Hi all,

Here's my update on the matter after upgrading quite everything. I would
like to thank those who replied to my questions.
First : I still have field parity problems with interlaced material on
interlaced TV.
Second : there are a lot things there, from the kernel, viafb,
libcle266mpegdec, DirectFB, DFB++, up to softdevice...


Kernel 2.6.17 Debian
* fresh compile and packaging

linux-viafb CVS 20061008 (today)
* applied viafb_flip_ioctl.patch from Mark Adams (transfered by Rolf
Ahrenberg and Laz today)
* this patch is really old, and does not apply totally cleanly on
today's CVS
* attached is un updated patch against current CVS (maybe Mark could
apply it to CVS if he have no better idea now about how to implement that ?)

libcle266mpegdec 0.4 (latest as of today) (oops : I didn't even try CVS)
* the GetFBOffset.patch isn't needed anymore with DirectFB 1.0rc1
* but GetFBOffsetDFB++.patch is still needed with DFB++ CVS
* maybe Rolf could get this patch integrated inside DFB++ before it
reaches 1.0rc stage ?

DirectFB 1.0rc1 (latest as of today)
* since GetFBOffset.patch is already applied, I only have to add
dfb_unichrome_flip_ioctl.patch from Mark Adams (transfered by Rolf
Ahrenberg and Laz today)
* here is the updated patch against 1.0rc1
* this patch was difficult to cleanly apply, because adjustments were
not correct (the code is so light and clean that patch select the wrong
function to apply a chunk, while the other was correctly placed)
(GetFBOffset.patch even applied cleanly, even though it was already in
place, and patch didn't see it)
* maybe Mark could add his patch to DirectFB CVS (if the freeze for 1.0
still allows that)
* to my knowledge, it is the only patch to apply to DirectFB
* see dfbinfo output attached (Caps: ... FIELD_PARITY ...)

DFB++ CVS 20061008 (today)
* applied the GetFBOffsetDFB++.patch from libcle266mpegdec
* this patch should make it into CVS, to keep in sync with DirectFB
* there is nothing about field parity there, since Mark's patch was
about the unichrome driver, not about DirectFB API (which DFB++ only
deals with)

softdevice CVS 20061008 (today)
* no patch to apply ?
* uses libclempegdec, viafb, etc.
* to attached log shows field parity is enabled ([softdevice] enabling
field parity / [softdevice] enabling CLE266 HW decoding)


I don't know what I miss to get rid of interlacing artifacts on TV out...


Nicolas Huillard a écrit :
> I'm a bit lost about what's needed for field parity correctness on
> TV-out with CLE266. I still have field artifacts on interlaced streams
> on TV-out.
> 
> My setup :
> VDR 1.4.2
> softdevice CVS 20060929 (-P softdevice -ao alsa:pcm=default -vo
> dfb:viatv:cle266)
> libcle266mpegdec 0.4
> DirectFB-2006-09-10-04-25-09-UTC
> DFB++-2006-09-10-04-25-02-UTC
> linux-viafb 20060910 (viafb mode=720x576 bpp=32 refresh=50 TVon=1
> TVoverscan=1)
> 
> I think I do not need any patches for linux-viafb (Mark Adams commited
> his patches to CVS)
> I don't know if I need something special in DirectFB/DFB++ (I applied
> libcle266mpegdec-0.3/patches/GetFBOffset.patch)
> I think the latest softdevice filed parity patches have joined CVS
> before I checked it out.

-- 
NH
diff -ur linux-viafb.orig/linux/drivers/video/cle266/via_fbobj.c linux-viafb/linux/drivers/video/cle266/via_fbobj.c
--- linux-viafb.orig/linux/drivers/video/cle266/via_fbobj.c	2006-04-18 16:11:28.000000000 +0200
+++ linux-viafb/linux/drivers/video/cle266/via_fbobj.c	2006-10-08 14:56:55.000000000 +0200
@@ -49,6 +49,9 @@
 #ifndef FBIO_WAITFORVSYNC
 #define FBIO_WAITFORVSYNC   _IOW('F', 0x20, u_int32_t)
 #endif
+#ifndef FBIO_FLIPONVSYNC
+#define FBIO_FLIPONVSYNC    _IOWR('F', 0x21, struct fb_flip)
+#endif
 
 static struct fb_fix_screeninfo viafb_fix __initdata = {
     .id =       "UNICHROME", 
@@ -75,6 +78,12 @@
 #define t_inb(reg)          inb(reg)
 #endif
 
+#define V1_STARTADDR_0                  0x254
+#define V1_STARTADDR_CR0                0x2F0
+#define V1_STARTADDR_CB0                0x28C
+#define V_COMPOSE_MODE                  0x298
+#define V1_COMMAND_FIRE                 0x80000000
+
 #define VERSION     "1.0"
 
 int VIACheckTVExist(struct fb_info *info);
@@ -1263,6 +1272,10 @@
     {
         ret = wait_event_interruptible_timeout(p->wq, (cnt != p->irq_cnt) && ((p->irq_cnt & 1)==1), HZ/10);
     }
+    else if (field_option == 3) // wait for any pending flip to complete
+    {
+        ret = wait_event_interruptible_timeout(p->wq, p->flip_pending == 0, HZ/10);
+    }
 
     if (ret < 0) {
         return ret;
@@ -1274,6 +1287,21 @@
     return 0;
 }
 
+static int viafb_flip_on_sync(struct fb_info *info, struct fb_flip *flip)
+{
+    struct via_par * p = (struct via_par *)info->par;
+    
+    if (flip->device == VIAFB_FLIP_V1)
+    {
+        p->flip = *flip;
+        flip->field = p->irq_cnt % 2;
+        flip->count = p->irq_cnt / 2;
+        p->flip_pending = 1;
+        return 0;
+    }
+    return -EINVAL;
+}
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
 static int viafb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
     unsigned long arg, struct fb_info *info)
@@ -1291,6 +1319,23 @@
             
             return viafb_wait_for_sync(info, field_option);
         }
+        case FBIO_FLIPONVSYNC:
+        {
+            struct fb_flip flip;
+            int err;
+
+            if (copy_from_user(&flip, (void __user *)arg, sizeof(flip)))
+                return -EFAULT;
+
+            err = viafb_flip_on_sync(info, &flip);
+            if (err)
+                return err;
+
+            if (copy_to_user((void __user *)arg, &flip, sizeof(flip)))
+                return -EFAULT;
+
+            return 0;
+        }
     }
 
     return -ENOTTY;
@@ -1308,6 +1353,14 @@
         VIASETREG(p->io_base_virt, VIA_REG_INTERRUPT, status | VIA_IRQ_VBI_PENDING);
 
         p->irq_cnt++;
+        if (p->flip_pending && ((p->irq_cnt & 1) == p->flip.field))
+        {
+            VIASETREG(p->io_base_virt, V1_STARTADDR_0, p->flip.offset[0]);
+            VIASETREG(p->io_base_virt, V1_STARTADDR_CB0, p->flip.offset[1]);
+            VIASETREG(p->io_base_virt, V1_STARTADDR_CR0, p->flip.offset[2]);
+            VIASETREG(p->io_base_virt, V_COMPOSE_MODE, VIAGETREG(p->io_base_virt, V_COMPOSE_MODE)|V1_COMMAND_FIRE);
+            p->flip_pending = 0;
+        }
         wake_up_interruptible(&p->wq);
         handled = 1;
     }
@@ -1537,6 +1590,8 @@
     current_par->TVoverscan = TVoverscan;
     current_par->TVEncoder = TVEncoder;
     
+    current_par->flip_pending = 0;
+    
     if (TVon) {
         VIACheckTVExist(info);
         if (default_xres==640 && default_yres==480)
diff -ur linux-viafb.orig/linux/drivers/video/cle266/via_fbobj.h linux-viafb/linux/drivers/video/cle266/via_fbobj.h
--- linux-viafb.orig/linux/drivers/video/cle266/via_fbobj.h	2005-11-04 13:39:38.000000000 +0100
+++ linux-viafb/linux/drivers/video/cle266/via_fbobj.h	2006-10-08 14:55:07.000000000 +0200
@@ -33,6 +33,18 @@
 
 #define CLE266          0x3122
 
+struct fb_flip {
+    u32 device;
+    u32 field;
+    u32 count;
+    u32 offset[6];
+};
+
+#define VIAFB_FLIP_GRAPHICS 0
+#define VIAFB_FLIP_V1 1
+#define VIAFB_FLIP_V3 2
+#define VIAFB_FLIP_SPIC 3
+
 /* 
  * This structure defines the hardware state of the graphics card. Normally
  * you place this in a header file in linux/include/video. This file usually
@@ -69,6 +81,9 @@
     wait_queue_head_t wq;
     
     int vclk;       // in MHz
+    
+    struct fb_flip flip;
+    int flip_pending;
 };
 
 #define VIASETREG(mmio, addr, data)   *(volatile u32 *)((mmio) +(addr)) = (data)
diff -ur DirectFB-1.0.0-rc1.orig/gfxdrivers/unichrome/uc_overlay.c DirectFB-1.0.0-rc1/gfxdrivers/unichrome/uc_overlay.c
--- DirectFB-1.0.0-rc1.orig/gfxdrivers/unichrome/uc_overlay.c	2006-09-13 19:22:53.000000000 +0200
+++ DirectFB-1.0.0-rc1/gfxdrivers/unichrome/uc_overlay.c	2006-10-08 16:53:05.000000000 +0200
@@ -24,6 +24,22 @@
 
 #include <misc/conf.h>
 
+struct fb_flip {
+    __u32 device;
+    __u32 field;
+    __u32 count;
+    __u32 offset[6];
+};
+
+#define VIAFB_FLIP_GRAPHICS 0
+#define VIAFB_FLIP_V1 1
+#define VIAFB_FLIP_V3 2
+#define VIAFB_FLIP_SPIC 3
+
+#ifndef FBIO_FLIPONVSYNC
+#define FBIO_FLIPONVSYNC    _IOWR('F', 0x21, struct fb_flip)
+#endif
+
 // Forward declaration
 static DFBResult
 uc_ovl_remove(CoreLayer *layer,
@@ -125,6 +141,8 @@
     UcDriverData*  ucdrv = (UcDriverData*) driver_data;
     UcOverlayData* ucovl = (UcOverlayData*) layer_data;
     DFBRectangle   win;
+    FBDev *dfb_fbdev = dfb_system_data();
+    int field_option;
     
     /* remember configuration */
     ucovl->config = *config;
@@ -158,6 +176,9 @@
     ucovl->deinterlace = config->options & DLOP_DEINTERLACING;
     ucovl->surface     = surface;
 
+    field_option = 3;	// wait for any pending flip to complete
+    ioctl(dfb_fbdev->fd, FBIO_WAITFORVSYNC, &field_option);
+    
     return uc_ovl_update(ucdrv, ucovl, UC_OVL_CHANGE, surface);
 }
 
@@ -268,6 +289,7 @@
 
     ucovl->field = 0;
 
+#if 0
     if (ucovl->config.options & DLOP_FIELD_PARITY)
     {
         int field_option;
@@ -286,6 +308,33 @@
     ret = uc_ovl_update(ucdrv, ucovl, UC_OVL_FLIP, surface);
     if (ret)
         return ret;
+#else
+    if (ucovl->config.options & DLOP_FIELD_PARITY)
+    {
+        struct fb_flip flip;
+        int field_option;
+        
+        field_option = 3;	// wait for last pending flip to complete
+        ioctl(dfb_fbdev->fd, FBIO_WAITFORVSYNC, &field_option);
+        
+        flip.device = VIAFB_FLIP_V1;
+        flip.field = ucovl->config.parity;
+        flip.count = 0;	// until we implement this
+        
+        uc_ovl_map_buffer(surface->format, surface->front_buffer->video.offset,
+            ucovl->v1.ox, ucovl->v1.oy, surface->width, surface->height,
+            surface->front_buffer->video.pitch, 0,
+            &flip.offset[0], &flip.offset[1], &flip.offset[2]);
+        
+        ioctl(dfb_fbdev->fd, FBIO_FLIPONVSYNC, &flip);
+    }
+    else
+    {
+        ret = uc_ovl_update(ucdrv, ucovl, UC_OVL_FLIP, surface);
+        if (ret)
+            return ret;
+    }
+#endif
 
     if (flags & DSFLIP_WAIT)
         dfb_layer_wait_vsync(layer);
diff -ur DirectFB-1.0.0-rc1.orig/lib/fusion/build.h DirectFB-1.0.0-rc1/lib/fusion/build.h
--- DirectFB-1.0.0-rc1.orig/lib/fusion/build.h	2006-10-01 11:32:41.000000000 +0200
+++ DirectFB-1.0.0-rc1/lib/fusion/build.h	2006-10-08 16:20:49.000000000 +0200
@@ -28,7 +28,7 @@
 #ifndef __FUSION__BUILD_H__
 #define __FUSION__BUILD_H__
 
-#define FUSION_BUILD_MULTI   (1)
+#define FUSION_BUILD_MULTI   (0)
 
 #endif
 
vdr: warning - cannot set dumpable: Invalid argument
[softdevice] processing args
[softdevice]   argv [0] = softdevice
[softdevice]   argv [1] = -ao
[softdevice] using alsa device default
[softdevice]   argv [3] = -vo
[softdevice] enabling field parity
[softdevice] enabling CLE266 HW decoding
[setup-softdevice] alsa ac3Mode set to: 1
[setup-softdevice] alsa AC3 device set to: spdif
[setup-softdevice] A/V Offset set to (0)
[setup-softdevice] Cropping 0 lines from bottom
[setup-softdevice] Cropping 0 columns from left
[setup-softdevice] cropping mode set to 2 (16:9)
[setup-softdevice] cropping mode toggle key set to 2 (User2)
[setup-softdevice] Cropping 0 columns from right
[setup-softdevice] Cropping 0 lines from top
[setup-softdevice] deinterlace method set to 0 none
[setup-softdevice] mainMenu: 1
[setup-softdevice] setting alpha blend mode to pseudo
[softdevice] picture mirroring set to 0 (off)
[setup-softdevice] pixel format set to (I420)
[setup-softdevice] shouldSuspend to: 0
[setup-softdevice] syncTimerMode: sig
[softdevice] UseStretchBlitset to off
[setup-softdevice] vidBrightness: 50
[setup-softdevice] vidContrast: 50
[setup-softdevice] vidHue: 50
[setup-softdevice] vidSaturation: 50
[setup-softdevice] startup aspect set to (4:3 normal)
[softdevice] initializing Plugin
[softdevice] Initializing Video Out
[softdevice] ffmpeg build(3344384)
[dfb] init

     =======================|  DirectFB 1.0.0-rc1  |=======================
          (c) 2001-2006  United Cultures of Earth - go for outer space!
          (c) 2000-2004  Convergence (integrated media) GmbH
        ----------------------------------------------------------------

(*) DirectFB/Core: Single Application Core. (2006-10-08 14:41) 
(*) Direct/Memcpy: Using MMXEXT optimized memcpy()
(*) Direct/Modules: suppress module 'joystick'
(*) Direct/Thread: Running 'LiRC Input' (INPUT, 3328)...
(*) DirectFB/Input: LIRC Device 0.2 (convergence integrated media GmbH)
(*) DirectFB/Genefx: MMX detected and enabled
(!) DirectFB/Unichrome: Failed to determine hardware revision, assuming 17.
(*) DirectFB/Graphics: VIA/S3G CLE266/UniChrome 0.4 (-)
(*) DirectFB/Core/WM: Default 0.2 (Convergence GmbH)
[dfb] RAM: 33288192 bytes
[dfb] Accellerated Functions: FillRectange DrawRectange DrawLine FillTriangle Blit StretchBlit All 
[dfb] Drawing Flags: Blend Xor 
[dfb] Surface Blitting Flags: BlendAlpha BlendColorAlpha Colorize SrcColorkey DstColorkey Deinterlace 
[dfb] Supported video Modes are: [EMAIL PROTECTED] [EMAIL PROTECTED] 
[dfb] Enumerating display Layers
[dfb] Configuring CooperativeLevel for OSD
Layer 0 VIA CLE266 Graphics  Type: graphics 
  Caps: alphachannel brightness contrast opacity saturation src_colorkey surface 
Layer 1 VIA Unichrome Video  Type: graphics picture video 
  Caps: deinterlacing dst_colorkey levels field_parity opacity screen_location surface 
Initialising CLE266 decoder (/dev/fb0): success!
CLE266: Creating buffers for decoder
CLE266: Creating buffer number 0
CLE266: Creating buffer number 1
CLE266: Creating buffer number 2
CLE266: Creating buffer number 3
CLE266: passing mpegfb_stride
CLE266: passing buffers to decoder
[dfb] (osdLayer): flags, options, pixelformat: 0000000f, 00000000 00418c04
[dfb] (osdLayer): width, height:               720 576
[dfb] osdLayer has alpha channel
[dfb] Set DLBM_TRIPLE for layer [VIA Unichrome Video]
[dfb] DLOP_FIELD_PARITY supported by layer [VIA Unichrome Video]
[surface capabilities] scrSurface: videoonly double-buffered flipping PixelFormat = 0x00418c04 
[dfb] width = 720, height = 576
[dfb] got fmt = 0x00418c04 bpp = 32
[dfb] Using this layer for OSD: (VIA CLE266 Graphics - [720x576])
[surface capabilities] osdSurface: videoonly double-buffered flipping PixelFormat = 0x00418c04 
[dfb] Configuring CooperativeLevel for Overlay
[surface capabilities] videoSurface: videoonly PixelFormat = 0x0810060a 
[dfb] Using this layer for OSD:        VIA CLE266 Graphics
[dfb] Using this layer for Video out:  VIA Unichrome Video
[dfb] Display frame time is 19995 microseconds
[dfb] (re)configuring Videolayer to 720 x 576 (720x576)
[dfb] SetParams: Enabling DLOP_FIELD_PARITY
[surface capabilities] videoSurface: videoonly flipping triple-buffered PixelFormat = 0x08100609 
[dfb] (re)configured 0x08100609
[softdevice] Subplugin successfully opend
[softdevice] Video Out seems to be OK
[softdevice] Initializing Audio Out
[softdevice] Audio out seems to be OK
[softdevice] A/V devices initialized, now initializing MPEG2 Decoder
[dfb] (re)configuring Videolayer to 736 x 576 (736x416)
[dfb] SetParams: Enabling DLOP_FIELD_PARITY
[surface capabilities] videoSurface: videoonly flipping triple-buffered PixelFormat = 0x08100609 
[dfb] (re)configured 0x08100609
     =======================|  DirectFB 1.0.0-rc1  |=======================
          (c) 2001-2006  United Cultures of Earth - go for outer space!
          (c) 2000-2004  Convergence (integrated media) GmbH
        ----------------------------------------------------------------

(*) DirectFB/Core: Single Application Core. (2006-10-08 14:41) 
(*) Direct/Memcpy: Using SSE optimized memcpy()
(*) Direct/Modules: suppress module 'joystick'
(*) Direct/Thread: Running 'LiRC Input' (INPUT, 3460)...
(*) DirectFB/Input: LIRC Device 0.2 (convergence integrated media GmbH)
(*) DirectFB/Genefx: MMX detected and enabled
(!) DirectFB/Unichrome: Failed to determine hardware revision, assuming 17.
(*) DirectFB/Graphics: VIA/S3G CLE266/UniChrome 0.4 (-)
(*) DirectFB/Core/WM: Default 0.2 (Convergence GmbH)


Screen (00) FBDev Primary Screen            (primary screen)
   Caps: VSYNC POWER_MANAGEMENT 

     Layer (00) VIA CLE266 Graphics             (primary layer)
        Type:    GRAPHICS 
        Caps:    SURFACE OPACITY ALPHACHANNEL SRC_COLORKEY BRIGHTNESS CONTRAST SATURATION 

     Layer (01) VIA Unichrome Video           
        Type:    GRAPHICS VIDEO STILL_PICTURE 
        Caps:    SURFACE OPACITY SCREEN_LOCATION DEINTERLACING DST_COLORKEY LEVELS FIELD_PARITY SCREEN_POSITION SCREEN_SIZE 

     Layer (02) VIA Unichrome DVD Subpicture  
        Type:    GRAPHICS VIDEO STILL_PICTURE 
        Caps:    SURFACE OPACITY 


Input (03) LIRC Device                     (primary remote control)
   Type: REMOTE 
   Caps: KEYS 

_______________________________________________
Softdevice-devel mailing list
Softdevice-devel@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/softdevice-devel

Reply via email to