Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Re: [PATCH] softdevice-0.0.5 for vdr-1.3.7
Stefan Lucke wrote:
Thanks, so I'll merge this with my last mile changes
(changed (f)print() to dsyslog(), dropped round() from audio.c)
and upload softdevice-0.0.6pre1 this evening.
Please apply also the included patch. It contains
changes for the DirectFB driver.
Vadim Catana
diff -urN ./softdevice-0.0.5/Makefile ./softdevice/Makefile
--- ./softdevice-0.0.5/Makefile 2004-05-19 13:08:27.534208024 +0300
+++ ./softdevice/Makefile 2004-05-19 10:23:27.000000000 +0300
@@ -25,7 +25,7 @@
#XV_SUPPORT=1
# DFB is very experimental (works only with my matrox G200, comments are welcome)
-#DFB_SUPPORT=1
+DFB_SUPPORT=1
# FB is unaccellerated and should work with any FB with 16bit color depth
#FB_SUPPORT=1
diff -urN ./softdevice-0.0.5/video-dfb.c ./softdevice/video-dfb.c
--- ./softdevice-0.0.5/video-dfb.c 2004-05-19 13:08:27.541206960 +0300
+++ ./softdevice/video-dfb.c 2004-05-19 13:06:12.026808280 +0300
@@ -6,7 +6,6 @@
* $Id: video-dfb.c,v 1.1.1.1 2004/04/24 07:03:18 stefan Exp $
*/
-
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <fcntl.h>
@@ -15,16 +14,16 @@
#include "utils.h"
#define COLORKEY 17,8,79
+
// --- cDFBVideoOut -------------------------------------------------
-// ich kann das nicht in die Klasse ienbinden, aber das ist mir jetzt egal!
IDirectFB *DFBWrapper;
-static DFBEnumerationResult EnumCallBack( unsigned int id,
- DFBDisplayLayerDescription desc,
- void *data ) {
+
+static DFBEnumerationResult EnumCallBack( unsigned int id, DFBDisplayLayerDescription desc, void *data )
+{
IDirectFBDisplayLayer **layer = (IDirectFBDisplayLayer **)data;
- printf("------ Layer %d ",id);
- if (id == DLID_PRIMARY) printf("(Primary layer)");
- printf(" %s -----\n", desc.name);
+
+ printf("Layer %d %s",id, desc.name);
+
printf(" Type: ");
if (desc.type & DLTF_BACKGROUND) printf( "background " );
if (desc.type & DLTF_GRAPHICS) printf( "graphics " );
@@ -46,41 +45,44 @@
if (desc.caps & DLCAPS_SCREEN_LOCATION) printf( "screen_location " );
if (desc.caps & DLCAPS_SRC_COLORKEY) printf( "src_colorkey " );
if (desc.caps & DLCAPS_SURFACE) printf( "surface " );
+ printf("\n");
/* We take the first layer not being the primary */
if (id != DLID_PRIMARY && desc.caps & DLCAPS_SURFACE) {
- printf(" (This is our videoLayer)\n");
+ printf(" This is our videoLayer\n");
try {
*layer = DFBWrapper->GetDisplayLayer(id);
} catch (DFBException *ex) {
-// cerr << "Caught: " << ex << endl;
+ printf( "Caught: %s", ex);
return DFENUM_CANCEL;
}
}
- printf("\n");
+
return DFENUM_OK;
}
// List Video Modes
-static DFBEnumerationResult EnumVideoModeCallback(int x, int y, int bpp, void *data) {
+static DFBEnumerationResult EnumVideoModeCallback(int x, int y, int bpp, void *data)
+{
printf("%dx%d@%d ",x,y,bpp);
return DFENUM_OK;
}
-
-
cDFBVideoOut::cDFBVideoOut()
{
DFBSurfaceDescription dsc;
DFBDisplayLayerDescription desc;
+ DFBCardCapabilities caps;
+
printf("[dfb] init\n");
DirectFB::Init();
dfb = DirectFB::Create();
dfb->SetCooperativeLevel(DFSCL_EXCLUSIVE);
- DFBCardCapabilities caps;
dfb->GetCardCapabilities(&caps);
+
printf("[dfb] RAM: %d bytes\n",caps.video_memory);
+
printf("[dfb] Accellerated Functions: ");
if (caps.acceleration_mask & DFXL_NONE) printf("none ");
if (caps.acceleration_mask & DFXL_FILLRECTANGLE) printf("FillRectange ");
@@ -90,7 +92,7 @@
if (caps.acceleration_mask & DFXL_BLIT) printf("Blit ");
if (caps.acceleration_mask & DFXL_STRETCHBLIT) printf("StretchBlit ");
if (caps.acceleration_mask & DFXL_ALL) printf("All ");
- printf("\n\n");
+ printf("\n");
printf("[dfb] Drawing Flags: ");
if (caps.drawing_flags == DSDRAW_NOFX ) printf("none ");
@@ -100,7 +102,7 @@
if (caps.drawing_flags & DSDRAW_DST_PREMULTIPLY ) printf("Dst.premultiply ");
if (caps.drawing_flags & DSDRAW_DEMULTIPLY ) printf("Demultiply ");
if (caps.drawing_flags & DSDRAW_XOR ) printf("Xor ");
- printf("\n\n");
+ printf("\n");
printf("[dfb] Surface Blitting Flags: ");
if (caps.blitting_flags == DSBLIT_NOFX ) printf("none ");
@@ -113,29 +115,27 @@
if (caps.blitting_flags & DSBLIT_DST_PREMULTIPLY ) printf("DstPremultiply ");
if (caps.blitting_flags & DSBLIT_DEMULTIPLY ) printf("Demultiply ");
if (caps.blitting_flags & DSBLIT_DEINTERLACE ) printf("Deinterlace ");
- printf("\n\n");
+ printf("\n");
-/* printf("[dfb] Supported video Modes are:\n");
+ printf("[dfb] Supported video Modes are: ");
dfb->EnumVideoModes(EnumVideoModeCallback, NULL);
printf("\n");
- sleep(3);*/
Xres = 768;
Yres = 576;
- Bpp = 32;
+ Bpp = 32;
+
try {
printf("[dfb] Setting Videomode to 768x576-32\n");
dfb->SetVideoMode(Xres,Yres,Bpp); // 768 x 576 @ 32bpp is the best choice for TV-Out
} catch (DFBException *ex) {
- //printf("[dfb] Caught: %s\n", ex);
try {
printf("[dfb] This didn't work. Trying Videomode 1024x768-32\n");
Xres = 1024;
Yres = 768;
- Bpp = 32;
+ Bpp = 32;
dfb->SetVideoMode(Xres,Yres,Bpp); // evtl hier andere Modes probieren
} catch (DFBException *ex) {
- //printf("[dfb] Caught: %s\n", ex);
printf("[dfb] This Vidmode doen't work, too. Exiting...\n");
exit(1);
}
@@ -146,34 +146,27 @@
dsc.flags = DSDESC_CAPS;
DFB_ADD_SURFACE_CAPS(dsc.caps, DSCAPS_PRIMARY);
DFB_ADD_SURFACE_CAPS(dsc.caps, DSCAPS_FLIPPING);
- osdSurface=dfb->CreateSurface(dsc);
-
-/* videoSurface=videoLayer->GetSurface();
- printf("clearing");
- videoSurface->Clear(1,1,1,0); //clear and
- videoSurface->Flip(); // Flip the field
-*/
- // für ColorKeying
+ osdSurface=dfb->CreateSurface(dsc);
osdSurface->Clear(COLORKEY,0); //clear and
osdSurface->Flip(); // Flip the field
osdSurface->Clear(COLORKEY,0); //clear and
osdSurface->Flip(); // Flip the field
- printf("[dfb] Screen should have a dark blue color now (my birthday :-)\n");
- DFBWrapper=dfb; // argh, bloede callback Funktion
+ DFBWrapper=dfb;
printf("[dfb] Enumeratig display Layers\n");
dfb->EnumDisplayLayers(EnumCallBack, &videoLayer);
-// override autodetect:
-// videoLayer=dfb->GetDisplayLayer(1);
-
+ videoSurface=videoLayer->GetSurface();
+ videoSurface->Clear(COLORKEY,0); //clear and
+ videoSurface->Flip(); // Flip the field
+ videoSurface->Clear(COLORKEY,0); //clear and
+ videoSurface->Flip(); // Flip the field
+
if(!videoLayer) {
printf("could not find suitable videolayer\n");
exit(1);
} else {
- // Hier stürzt DFB mit meiner Nvidia Karte immer ab
-/*
desc = osdLayer->GetDescription();
printf("Using this layer for OSD: %s\n", desc.name);
printf("Size: %d x %d \n",osdSurface->GetWidth(), osdSurface->GetHeight());
@@ -201,9 +194,9 @@
if (scaps & DSCAPS_INTERLACED) printf(" - interlaced\n");
if (scaps & DSCAPS_SEPARATED) printf(" - separated\n");
if (scaps & DSCAPS_STATIC_ALLOC) printf(" - static alloc\n");
- if (scaps & DSCAPS_TRIPLE) printf(" - triple buffered\n");*/
-
+ if (scaps & DSCAPS_TRIPLE) printf(" - triple buffered\n");
}
+
// evtl wird die eine oder andere Funktion nicht von der Graka unterstuetzt
printf("[dfb] Configuring CooperativeLevel for Overlay\n");
videoLayer->SetCooperativeLevel(DLSCL_ADMINISTRATIVE);
@@ -220,72 +213,148 @@
}
-void cDFBVideoOut::SetParams(int newXres, int newYres) {
- if (videoLayer) {
- if (!videoSurface || (ovlXres !=newXres) || (ovlYres != newYres)) {
- printf("[dfb] (re)configuring Videolayer to %d x %d \n", newXres,newYres);
- DFBDisplayLayerDescription desc;
-// desc = videoLayer->GetDescription();
-
-
- DFBDisplayLayerConfig dlc;
-
- dlc.flags = (DFBDisplayLayerConfigFlags)(DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | DLCONF_OPTIONS);
- dlc.width = newXres;
- dlc.height = newYres;
- dlc.pixelformat = DSPF_YUY2; // i420 and others are too complex, YUY2 supported by nearly every Graka
- dlc.options = (DFBDisplayLayerOptions)(DLOP_DST_COLORKEY | DLOP_DEINTERLACING ); // maybe your graphic card does not support this
- // dlc.buffermode = DLBM_BACKVIDEO;
- // dlc.options = (DFBDisplayLayerOptions)(DLOP_NONE ); // maybe you should try this
- try {
- videoLayer->SetConfiguration(dlc);
- } catch (DFBException *ex) {
- //cerr << "Caught: " << ex << endl;
- exit(1);
- }
+void cDFBVideoOut::SetParams(int newXres, int newYres)
+{
+ DFBDisplayLayerConfig dlc;
+ DFBDisplayLayerDescription desc;
- //if (desc.caps & DLCAPS_SCREEN_LOCATION) {
- videoLayer->SetScreenLocation(0.0f, 0.0f, 0.9999f, 1.0f); // my Matrox doesn't wor when setting to 0.0 0.0 1.0 1.0
- //} else {
- // printf("Can't configure ScreenLocation. Hope it is Fullscreen\n");
- //}
- videoSurface=videoLayer->GetSurface();
- ovlXres = newXres;
- ovlYres = newYres;
- printf("[dfb] (re)configured\n");
- }
+ if (videoLayer)
+ {
+ if (!videoSurface || (ovlXres !=newXres) || (ovlYres != newYres))
+ {
+ printf("[dfb] (re)configuring Videolayer to %d x %d \n", newXres,newYres);
+
+ dlc.flags = (DFBDisplayLayerConfigFlags)(DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | DLCONF_OPTIONS);
+ dlc.width = newXres;
+ dlc.height = newYres;
+ dlc.options = (DFBDisplayLayerOptions)(DLOP_DST_COLORKEY | DLOP_DEINTERLACING ); // maybe your graphic card does not support this
+
+ dlc.pixelformat = DSPF_I420;
+// dlc.pixelformat = DSPF_YUY2;
+
+ dlc.options = (DFBDisplayLayerOptions)( DLOP_ALPHACHANNEL );
+// dlc.options = (DFBDisplayLayerOptions)( DLOP_DST_COLORKEY | DLOP_DEINTERLACING ); // maybe your graphic card does not support this
+// dlc.options = (DFBDisplayLayerOptions)( DLOP_NONE ); // maybe you should try this
+
+ pixelformat = dlc.pixelformat;
+
+ try {
+ videoLayer->SetConfiguration(dlc);
+ } catch (DFBException *ex) {
+ printf("Caught: %s", ex);
+ exit(1);
+ }
+
+ desc = videoLayer->GetDescription();
+
+ if (desc.caps & DLCAPS_SCREEN_LOCATION) {
+ videoLayer->SetScreenLocation(0.0f, 0.0f, 0.9999f, 1.0f); // my Matrox doesn't wor when setting to 0.0 0.0 1.0 1.0
+ } else {
+ printf("Can't configure ScreenLocation. Hope it is Fullscreen\n");
+ }
+
+ videoSurface=videoLayer->GetSurface();
+ ovlXres = newXres;
+ ovlYres = newYres;
+ printf("[dfb] (re)configured\n");
+ }
} else {
printf("No Videolayer avaiable. Exiting...\n");
exit(1);
- }
+ }
}
void cDFBVideoOut::Pause(void)
{
}
-void cDFBVideoOut::Refresh() {
- // refreshes the OSD screen
+#if VDRVERSNUM >= 10307
+
+void cDFBVideoOut::Refresh(cBitmap *Bitmap)
+{
+ const tIndex *adr;
+ tIndex *buf;
+ tColor c;
int pitch;
uint8_t *dst;
- osdSurface->Clear(COLORKEY,0); //clear and
+
osdSurface->Lock(DSLF_WRITE, (void **)&dst, &pitch) ;
- for (int i = 0; i < MAXNUMWINDOWS; i++) {
- if (layer[i] && layer[i]->visible) layer[i]->Draw(dst, pitch, NULL);
+
+ for (int y = 0; y < Bitmap->Height(); y++)
+ {
+ buf = (tIndex *) dst + pitch * ( OSDyOfs + y ) + OSDxOfs * 4;
+
+ for (int x = 0; x < Bitmap->Width(); x++)
+ {
+ adr = Bitmap->Data(x, y);
+ c = Bitmap->Color(*adr);
+
+ buf[3] = (c >> 24) & 255; //Alpha
+ buf[2] = (c >> 16) & 255; //Red
+ buf[1] = (c >> 8) & 255; //Green
+ buf[0] = c & 255; //Blue
+
+ buf+=4;
}
+ }
+
+ osdSurface->Unlock();
+ osdSurface->Flip();
+}
+
+#else
+
+void cDFBVideoOut::Refresh()
+{
+ int pitch;
+ uint8_t *dst;
+
+ osdSurface->Lock(DSLF_WRITE, (void **)&dst, &pitch) ;
+ for (int i = 0; i < MAXNUMWINDOWS; i++) {
+ if (layer[i] && layer[i]->visible) layer[i]->Draw(dst, pitch, NULL);
+ }
osdSurface->Unlock();
osdSurface->Flip();
}
+#endif
void cDFBVideoOut::YUV(uint8_t *Py, uint8_t *Pu, uint8_t *Pv, int Width, int Height, int Ystride, int UVstride)
{
- SetParams(Width, Height);
uint8_t *dst;
int pitch;
-// printf("[dfb] draw frame (%d x %d) Y: %d UV: %d\n", Width, Height, Ystride, UVstride);
+ int hi;
+
+ SetParams(Width, Height);
+
+// printf("[dfb] draw frame (%d x %d) Y: %d UV: %d\n", Width, Height, Ystride, UVstride);
+
videoSurface->Lock(DSLF_WRITE, (void **)&dst, &pitch);
- if (videoLayer) { // pack the pixel
+
+ if (pixelformat == DSPF_I420)
+ {
+ for(hi=0; hi < Height; hi++){
+ memcpy(dst, Py, Width);
+ Py += Ystride;
+ dst += pitch;
+ }
+
+ for(hi=0; hi < Height/2; hi++) {
+ memcpy(dst, Pu, Width/2);
+ Pu += UVstride;
+ dst += pitch / 2;
+ }
+
+ for(hi=0; hi < Height/2; hi++) {
+ memcpy(dst, Pv, Width/2);
+ Pv += UVstride;
+ dst += pitch / 2;
+ }
+
+ videoSurface->Unlock();
+
+ } else if (pixelformat == DSPF_YUY2) {
+
#ifndef USE_MMX
/* reference implementation */
int p = pitch - Width*2;
@@ -301,7 +370,7 @@
dst +=1;
}
dst +=p;
- }
+ }
# else
/* deltas */
for (int i=0; i<Height; i++) {
@@ -311,7 +380,7 @@
py = Py;
srfc = dst;
for (int j =0; j < Width/8; j++) {
- movd_m2r(*pu, mm1); // mm1 = 00 00 00 00 U3 U2 U1 U0
+ movd_m2r(*pu, mm1); // mm1 = 00 00 00 00 U3 U2 U1 U0
movd_m2r(*pv, mm2); // mm2 = 00 00 00 00 V3 V2 V1 V0
movq_m2r(*py, mm0); // mm0 = Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
punpcklbw_r2r(mm2, mm1); // mm1 = V3 U3 V2 U2 V1 U1 V0 U0
@@ -334,11 +403,12 @@
Pv += UVstride;
}
dst += pitch;
- }
+ }
# endif
- }
- videoSurface->Unlock();
-/* try {
+ videoSurface->Unlock();
+ }
+/*
+ try {
videoSurface->Flip();
} catch (DFBException *ex){
printf("Flip failed\n");
@@ -346,24 +416,16 @@
*/
}
-void cDFBVideoOut::CloseOSD() {
+void cDFBVideoOut::CloseOSD()
+{
osdSurface->Clear(COLORKEY,0); //clear and
osdSurface->Flip(); // Flip the field
osdSurface->Clear(COLORKEY,0); //clear and
osdSurface->Flip(); // Flip the field
- printf("[dfb] OSD cleared\n");
}
-cDFBVideoOut::~cDFBVideoOut() {
+cDFBVideoOut::~cDFBVideoOut()
+{
printf("Releasing DFB\n");
- for (int i = 0; i < MAXNUMWINDOWS; i++) {
- //if (layer[i]) delete(layer[i]);
- }
- if (videoSurface) videoSurface->Release();
- if (videoLayer) videoLayer->Release();
- if (osdSurface) videoSurface->Release();
- if (osdLayer) videoLayer->Release();
if (dfb) dfb->Release();
- exit(1);
}
-
diff -urN ./softdevice-0.0.5/video-dfb.h ./softdevice/video-dfb.h
--- ./softdevice-0.0.5/video-dfb.h 2004-05-18 19:55:17.000000000 +0300
+++ ./softdevice/video-dfb.h 2004-05-19 13:14:12.807718472 +0300
@@ -19,24 +19,25 @@
IDirectFBDisplayLayer *videoLayer;
IDirectFBSurface *osdSurface;
IDirectFBSurface *videoSurface;
+ DFBSurfacePixelFormat pixelformat;
int ovlXres, ovlYres;
bool deinterlace;
bool alphablend;
void SetParams(int newXres, int newYres);
-
-// void ShowLayerProperties(IDirectFBDisplayLayer *layer);
-public:
-/* static DFBEnumerationResult EnumCallBack( unsigned int id,
- DFBDisplayLayerDescription desc,
- void *data );*/
+public:
cDFBVideoOut();
virtual ~cDFBVideoOut();
+
+#if VDRVERSNUM >= 10307
+ virtual void Refresh(cBitmap *Bitmap);
+#else
virtual void Refresh();
+#endif
+
virtual void YUV(uint8_t *Py, uint8_t *Pu, uint8_t *Pv, int Width, int Height, int Ystride, int UVstride);
virtual void Pause(void);
virtual void CloseOSD();
-
};
#endif // VIDEO_DFB_H
Home |
Main Index |
Thread Index