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 (!setMode(NORMAL)) { shutdown(); return 0; }
62 if (!setAspectRatio(ASPECT4X3)) { shutdown(); return 0; }
63 if (!setSource()) { shutdown(); return 0; }
64 if (!attachFrameBuffer()) { shutdown(); return 0; }
74 if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0;
75 if (!setSource()) { shutdown(); return 0; }
76 if (!attachFrameBuffer()) { shutdown(); return 0; }
83 if (!initted) return 0;
89 int Video::checkSCART()
91 // Returns 3 for SCART Composite out
92 // Returns 3 for SCART S-Video out
93 // Returns 2 for SCART RGB out
94 // Returns 3 for SCART not plugged in
96 // So, as you can have RGB and composite out simultaneously,
97 // and it can't detect S-Video, what is the point of this?
100 if (ioctl(fdVideo, AV_CHK_SCART, &scart) != 0) return -10;
105 int Video::setFormat(UCHAR tformat)
107 if (!initted) return 0;
108 if ((tformat != PAL) && (tformat != NTSC)) return 0;
111 if (ioctl(fdVideo, AV_SET_VID_DISP_FMT, format) != 0) return 0;
127 int Video::setConnection(UCHAR tconnection)
129 if (!initted) return 0;
130 if ((tconnection != COMPOSITERGB) && (tconnection != SVIDEO)) return 0;
131 connection = tconnection;
133 if (ioctl(fdVideo, AV_SET_VID_OUTPUT, connection) != 0) return 0;
137 int Video::setAspectRatio(UCHAR taspectRatio)
139 if (!initted) return 0;
140 if ((taspectRatio != ASPECT4X3) && (taspectRatio != ASPECT16X9)) return 0;
141 aspectRatio = taspectRatio;
143 if (ioctl(fdVideo, AV_SET_VID_RATIO, aspectRatio) != 0) return 0;
147 int Video::setMode(UCHAR tmode)
149 if (!initted) return 0;
151 if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH)
152 && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0;
157 // if (ioctl(fdVideo, AV_SET_VID_MODE, mode) != 0) return 0;
159 int a = ioctl(fdVideo, AV_SET_VID_MODE, mode);
160 printf("Mode requested: %i, result: %i\n", mode, a);
171 // return ioctl(fdVideo, AV_SET_VID_STC, &stc);
184 int Video::signalOff()
186 if (ioctl(fdVideo, AV_SET_VID_DENC, 0) != 0) return 0;
190 int Video::signalOn()
192 if (ioctl(fdVideo, AV_SET_VID_DENC, 1) != 0) return 0;
196 int Video::setSource()
198 if (!initted) return 0;
200 // What does this do...
201 if (ioctl(fdVideo, AV_SET_VID_SRC, 1) != 0) return 0;
205 int Video::setPosition(int x, int y)
207 if (!initted) return 0;
209 vid_pos_regs_t pos_d;
234 pos_d.y = 100; // Top left X
235 pos_d.x = 50; // Top left Y
243 if (ioctl(fdVideo, AV_SET_VID_POSITION, &pos_d) != 0) return 0;
249 if (!initted) return 0;
251 if (ioctl(fdVideo, AV_SET_VID_SYNC, 2) != 0) return 0;
257 if (!initted) return 0;
259 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
265 if (!initted) return 0;
267 if (ioctl(fdVideo, AV_SET_VID_STOP, 0) != 0) return 0;
273 if (!initted) return 0;
275 if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0;
281 if (!initted) return 0;
283 if (ioctl(fdVideo, AV_SET_VID_PAUSE, 0) != 0) return 0;
287 int Video::unPause() // FIXME get rid - same as play!!
289 if (!initted) return 0;
290 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
294 int Video::fastForward()
296 if (!initted) return 0;
298 if (ioctl(fdVideo, AV_SET_VID_FFWD, 1) != 0) return 0;
302 int Video::unFastForward()
304 if (!initted) return 0;
306 // if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0; // don't need this.
308 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
312 int Video::attachFrameBuffer()
314 if (!initted) return 0;
316 if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0;
320 int Video::blank(void)
322 if (ioctl(fdVideo, AV_SET_VID_FB, 1) != 0) return 0;
323 if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0;
329 if (!initted) return 0;
334 UCHAR Video::getFormat()
339 UINT Video::getScreenWidth()
344 UINT Video::getScreenHeight()