2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP 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 VOMP 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 VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 Video* Video::instance = NULL;
47 Video* Video::getInstance()
52 int Video::init(UCHAR tformat)
54 if (initted) return 0;
57 if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0;
59 if (!setFormat(tformat)) { shutdown(); return 0; }
60 if (!setConnection(COMPOSITERGB)) { shutdown(); return 0; }
61 if (!setAspectRatio(ASPECT4X3)) { shutdown(); return 0; }
62 if (!setMode(NORMAL)) { shutdown(); return 0; }
63 if (!setSource()) { shutdown(); return 0; }
64 if (!attachFrameBuffer()) { shutdown(); return 0; }
73 if (!initted) return 0;
79 int Video::write(char *buf, int len)
81 return 1;//write(fdVideo, buf, len);
84 int Video::checkSCART()
86 // Returns 3 for SCART Composite out
87 // Returns 3 for SCART S-Video out
88 // Returns 2 for SCART RGB out
89 // Returns 3 for SCART not plugged in
91 // So, as you can have RGB and composite out simultaneously,
92 // and it can't detect S-Video, what is the point of this?
95 if (ioctl(fdVideo, AV_CHK_SCART, &scart) != 0) return -10;
100 int Video::setFormat(UCHAR tformat)
102 if (!initted) return 0;
103 if ((tformat != PAL) && (tformat != NTSC)) return 0;
106 if (ioctl(fdVideo, AV_SET_VID_DISP_FMT, format) != 0) return 0;
122 int Video::setConnection(UCHAR tconnection)
124 if (!initted) return 0;
125 if ((tconnection != COMPOSITERGB) && (tconnection != SVIDEO)) return 0;
126 connection = tconnection;
128 if (ioctl(fdVideo, AV_SET_VID_OUTPUT, connection) != 0) return 0;
132 int Video::setAspectRatio(UCHAR taspectRatio)
134 if (!initted) return 0;
135 if ((taspectRatio != ASPECT4X3) && (taspectRatio != ASPECT16X9)) return 0;
136 aspectRatio = taspectRatio;
138 if (ioctl(fdVideo, AV_SET_VID_RATIO, aspectRatio) != 0) return 0;
142 int Video::setMode(UCHAR tmode)
144 if (!initted) return 0;
146 if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH)
147 && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0;
152 if (ioctl(fdVideo, AV_SET_VID_MODE, mode) != 0) return 0;
161 // return ioctl(fdVideo, AV_SET_VID_STC, &stc);
175 int Video::signalOff()
177 if (ioctl(fdVideo, AV_SET_VID_DENC, 0) != 0) return 0;
181 int Video::signalOn()
183 if (ioctl(fdVideo, AV_SET_VID_DENC, 1) != 0) return 0;
187 int Video::setSource()
189 if (!initted) return 0;
191 // What does this do...
192 if (ioctl(fdVideo, AV_SET_VID_SRC, 1) != 0) return 0;
196 int Video::setPosition(int x, int y)
198 if (!initted) return 0;
200 vid_pos_regs_t pos_d;
225 pos_d.y = 100; // Top left X
226 pos_d.x = 50; // Top left Y
234 if (ioctl(fdVideo, AV_SET_VID_POSITION, &pos_d) != 0) return 0;
240 if (!initted) return 0;
242 if (ioctl(fdVideo, AV_SET_VID_SYNC, 2) != 0) return 0;
248 if (!initted) return 0;
250 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
256 if (!initted) return 0;
258 if (ioctl(fdVideo, AV_SET_VID_STOP, 0) != 0) return 0;
264 if (!initted) return 0;
266 if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0;
272 if (!initted) return 0;
274 if (ioctl(fdVideo, AV_SET_VID_PAUSE, 0) != 0) return 0;
278 int Video::unPause() // FIXME get rid - same as play!!
280 if (!initted) return 0;
281 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
285 int Video::fastForward()
287 if (!initted) return 0;
289 if (ioctl(fdVideo, AV_SET_VID_FFWD, 1) != 0) return 0;
293 int Video::unFastForward()
295 if (!initted) return 0;
297 // if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0; // don't need this.
299 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
303 int Video::attachFrameBuffer()
305 if (!initted) return 0;
307 if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0;
311 int Video::blank(void)
313 if (ioctl(fdVideo, AV_SET_VID_FB, 1) != 0) return 0;
314 if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0;
320 if (!initted) return 0;
325 UCHAR Video::getFormat()
330 UINT Video::getScreenWidth()
335 UINT Video::getScreenHeight()