I just stumbled on DLOP_OPACITY and DLOP_ALPHACHANNEL and thought that the
CRTC2 sub-picture layer should honor these. So here's a patch to do just
that. I also included a patch to mplayer with the relevant changes.

-- 
Ville Syrj�l�
[EMAIL PROTECTED]
http://www.sci.fi/~syrjala/
diff -urN DirectFB/gfxdrivers/matrox/matrox_spic.c 
DirectFB/gfxdrivers/matrox/matrox_spic.c
--- DirectFB/gfxdrivers/matrox/matrox_spic.c    Thu Dec 19 22:53:38 2002
+++ DirectFB/gfxdrivers/matrox/matrox_spic.c    Thu Feb 13 06:38:29 2003
@@ -56,6 +56,8 @@
 #include "matrox_maven.h"
 
 typedef struct {
+     DFBDisplayLayerConfig config;
+
      /* Stored registers */
      struct {
           /* CRTC2 sub picture */
@@ -70,7 +72,7 @@
 static void spic_set_buffer( MatroxDriverData *mdrv, MatroxSpicLayerData *mspic,
                              DisplayLayer *layer );
 
-#define SPIC_SUPPORTED_OPTIONS   (DLOP_DEINTERLACING)
+#define SPIC_SUPPORTED_OPTIONS   (DLOP_ALPHACHANNEL | DLOP_OPACITY)
 
 /**********************/
 
@@ -90,7 +92,7 @@
                void                  *layer_data )
 {
      /* set capabilities and type */
-     layer_info->desc.caps = DLCAPS_SURFACE | DLCAPS_DEINTERLACING;
+     layer_info->desc.caps = DLCAPS_SURFACE | DLCAPS_ALPHACHANNEL | DLCAPS_OPACITY;
      layer_info->desc.type = DLTF_GRAPHICS | DLTF_VIDEO | DLTF_STILL_PICTURE;
 
      /* set name */
@@ -168,6 +170,11 @@
      if (config->options & ~SPIC_SUPPORTED_OPTIONS)
           fail |= DLCONF_OPTIONS;
 
+     /* Can't have both at the same time */
+     if (config->options & DLOP_ALPHACHANNEL &&
+         config->options & DLOP_OPACITY)
+          fail |= DLCONF_OPTIONS;
+
      switch (config->pixelformat) {
           case DSPF_LUT8:
                break;
@@ -199,6 +206,9 @@
      MatroxDriverData    *mdrv  = (MatroxDriverData*) driver_data;
      MatroxSpicLayerData *mspic = (MatroxSpicLayerData*) layer_data;
 
+     /* remember configuration */
+     mspic->config = *config;
+
      spic_set_buffer( mdrv, mspic, layer );
 
      return DFB_OK;
@@ -255,19 +265,26 @@
           case 0xFF:
                /* c2subpicen = 1 */
                mspic->regs.c2DATACTL |= (1 << 3);
-               /* c2statickeyen = 0 */
-               mspic->regs.c2DATACTL &= ~(1 << 5);
                break;
           default:
+               if (!(mspic->config.options & DLOP_OPACITY))
+                    return DFB_UNSUPPORTED;
+
                /* c2subpicen = 1 */
                mspic->regs.c2DATACTL |= (1 << 3);
-               /* c2statickeyen = 1 */
-               mspic->regs.c2DATACTL |= (1 << 5);
-               /* c2statickey */
-               mspic->regs.c2DATACTL &= ~0x1F000000;
-               mspic->regs.c2DATACTL |= ((opacity + 2) << 20) & 0x1F000000;
                break;
      }
+
+     if (mspic->config.options & DLOP_ALPHACHANNEL)
+          /* c2statickeyen = 0 */
+          mspic->regs.c2DATACTL &= ~(1 << 5);
+     else
+          /* c2statickeyen = 1 */
+          mspic->regs.c2DATACTL |= (1 << 5);
+
+     /* c2statickey */
+     mspic->regs.c2DATACTL &= ~0x1F000000;
+     mspic->regs.c2DATACTL |= ((opacity + 1) << 20) & 0x1F000000;
 
      mga_out32( mmio, mspic->regs.c2DATACTL, C2DATACTL);
 
--- mplayer/libvo/vo_dfbmga.c   Tue Jan 21 20:55:32 2003
+++ mplayer/libvo/vo_dfbmga.c   Thu Feb 13 10:00:19 2003
@@ -502,6 +502,10 @@
           dlc.flags       = DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE;
           dlc.pixelformat = DSPF_LUT8;
           dlc.buffermode  = DLBM_BACKVIDEO;
+#if DIRECTFBVERSION > 916
+          dlc.flags      |= DLCONF_OPTIONS;
+          dlc.options     = DLOP_ALPHACHANNEL;
+#endif
           if (spic->TestConfiguration( spic, &dlc, &failed ) != DFB_OK) {
                mp_msg( MSGT_VO, MSGL_ERR,
                        "vo_dfbmga: Invalid sub-picture configuration!\n" );

Reply via email to