2 * $Id: showlogo.cpp,v 1.6 2008/05/11 14:22:17 seife Exp $
4 * (C) 2005 by digi_casi <digi_casi@tuxbox.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #if HAVE_DVB_API_VERSION < 3
24 #include <ost/video.h>
25 #include <ost/audio.h>
26 #define VIDEO_DEV "/dev/dvb/card0/video0"
27 #define AUDIO_DEV "/dev/dvb/card0/audio0"
28 #define DEMUX_DEV "/dev/dvb/card0/demux0"
30 #include <linux/dvb/dmx.h>
31 #include <linux/dvb/video.h>
32 #include <linux/dvb/audio.h>
33 #define VIDEO_DEV "/dev/dvb/adapter0/video0"
34 #define AUDIO_DEV "/dev/dvb/adapter0/audio0"
35 #define DEMUX_DEV "/dev/dvb/adapter0/demux0"
36 #define audioStatus audio_status
37 #define videoStatus video_status
38 #define pesType pes_type
39 #define playState play_state
40 #define audioStreamSource_t audio_stream_source_t
41 #define videoStreamSource_t video_stream_source_t
42 #define streamSource stream_source
43 #define dmxPesFilterParams dmx_pes_filter_params
51 #include <sys/ioctl.h>
55 #include <lib/base/estring.h>
56 #include <lib/driver/eavswitch.h>
57 #include <dbox/avs_core.h>
66 #ifdef OLD_VBI // oldvbi header
67 #include <dbox/avia_gt_vbi.h>
70 // Non DVB API Functions and ioctls
72 #define VIDEO_FLUSH_CLIP_BUFFER 0
73 #define VIDEO_GET_PTS _IOR('o', 1, unsigned int*)
74 #define VIDEO_SET_AUTOFLUSH _IOW('o', 2, int)
75 #define VIDEO_CLEAR_SCREEN 3
76 #define VIDEO_SET_FASTZAP _IOW('o', 4, int)
78 #define SAAIOGREG 1 /* read registers */
79 #define SAAIOSINP 2 /* input control */
80 #define SAAIOSOUT 3 /* output control */
81 #define SAAIOSENC 4 /* set encoder (pal/ntsc) */
82 #define SAAIOSMODE 5 /* set mode (rgb/fbas/svideo/component) */
83 #define SAAIOSWSS 10 /* set wide screen signaling data */
85 #define SAA_MODE_RGB 0
86 #define SAA_MODE_FBAS 1
87 #define SAA_MODE_SVIDEO 2
88 #define SAA_MODE_COMPONENT 3
90 #define LOGO "/root/platform/kernel/bild"
92 int getKey(eString findkey
)
95 FILE *f
= fopen("/var/tuxbox/config/enigma/config", "r");
101 if (!fgets(buffer
, 1024, f
))
103 if (strlen(buffer
) < 4)
105 if (buffer
[0] == 'u')
107 eString b
= eString(buffer
);
108 b
= b
.right(b
.length() - 2);
109 unsigned int pos
= b
.find("=");
110 eString key
= b
.left(pos
);
113 printf("found key = %s\n", key
.c_str());
114 eString result
= b
.right(b
.length() - pos
- 1);
115 res
= atoi(result
.c_str());
122 printf("returning %d\n", res
);
126 int setColorFormat(eAVColorFormat c
)
128 printf("setting color format %d\n", c
);
129 int saafd
= open("/dev/dbox/saa0", O_RDWR
);
130 int avsfd
= open("/dev/dbox/avs0", O_RDWR
);
147 arg
=SAA_MODE_COMPONENT
;
150 int fblk
= ((c
== cfRGB
) || (c
== cfYPbPr
)) ? 1 : 0;
151 ioctl(saafd
, SAAIOSMODE
, &arg
);
152 ioctl(avsfd
, AVSIOSFBLK
, &fblk
);
158 void displayIFrame(const char *frame
, int len
)
160 int fdv
= open("/dev/video", O_WRONLY
);
163 int fdvideo
= open(VIDEO_DEV
, O_RDWR
);
164 ioctl(fdvideo
, VIDEO_SELECT_SOURCE
, VIDEO_SOURCE_MEMORY
);
165 ioctl(fdvideo
, VIDEO_CLEAR_BUFFER
);
166 ioctl(fdvideo
, VIDEO_PLAY
);
168 for (int i
= 0; i
< 2; i
++)
169 write(fdv
, frame
, len
);
171 unsigned char buf
[128];
172 memset(&buf
, 0, 128);
173 write(fdv
, &buf
, 128);
175 ioctl(fdv
, VIDEO_SET_AUTOFLUSH
, 0);
176 ioctl(fdvideo
, VIDEO_SET_BLANK
, 0);
178 ioctl(fdv
, VIDEO_SET_AUTOFLUSH
, 1);
184 void displayIFrameFromFile(const char *filename
)
186 int file
= open(filename
, O_RDONLY
);
189 int size
= lseek(file
, 0, SEEK_END
);
190 lseek(file
, 0, SEEK_SET
);
193 char *buffer
= new char[size
];
194 read(file
, buffer
, size
);
195 displayIFrame(buffer
, size
);
202 int main(int argc
, char **argv
)
204 char *logo
= (argc
< 2) ? strdup(LOGO
) : argv
[1];
205 int colorformat
= getKey("/elitedvb/video/colorformat");
206 setColorFormat((eAVColorFormat
)colorformat
);
207 displayIFrameFromFile(logo
);