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;
48 Video* Video::getInstance()
53 int Video::init(UCHAR tformat)
55 if (initted) return 0;
58 if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0;
60 if (!setFormat(tformat)) { shutdown(); return 0; }
61 if (!setConnection(COMPOSITERGB)) { shutdown(); return 0; }
62 if (!setAspectRatio(ASPECT4X3)) { shutdown(); return 0; }
63 if (!setMode(NORMAL)) { shutdown(); return 0; }
64 if (!setSource()) { shutdown(); return 0; }
65 if (!attachFrameBuffer()) { shutdown(); return 0; }
74 int Video::setTVsize(UCHAR ttvsize)
78 // Override the aspect ratio usage, temporarily use to set the video chip mode
79 if (!setAspectRatio(tvsize)) { shutdown(); return 0; }
81 if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0;
82 if (!setSource()) { shutdown(); return 0; }
83 if (!attachFrameBuffer()) { shutdown(); return 0; }
85 // Reopening the fd causes the scart aspect line to go back to 4:3
86 // Set this again to the same as the tv screen size
87 if (!setAspectRatio(tvsize)) { shutdown(); return 0; }
92 int Video::setDefaultAspect()
94 return setAspectRatio(tvsize);
99 if (!initted) return 0;
105 int Video::checkSCART()
107 // Returns 3 for SCART Composite out
108 // Returns 3 for SCART S-Video out
109 // Returns 2 for SCART RGB out
110 // Returns 3 for SCART not plugged in
112 // So, as you can have RGB and composite out simultaneously,
113 // and it can't detect S-Video, what is the point of this?
116 if (ioctl(fdVideo, AV_CHK_SCART, &scart) != 0) return -10;
121 int Video::setFormat(UCHAR tformat)
123 if (!initted) return 0;
124 if ((tformat != PAL) && (tformat != NTSC)) return 0;
127 if (ioctl(fdVideo, AV_SET_VID_DISP_FMT, format) != 0) return 0;
143 int Video::setConnection(UCHAR tconnection)
145 if (!initted) return 0;
146 if ((tconnection != COMPOSITERGB) && (tconnection != SVIDEO)) return 0;
147 connection = tconnection;
149 if (ioctl(fdVideo, AV_SET_VID_OUTPUT, connection) != 0) return 0;
153 int Video::setAspectRatio(UCHAR taspectRatio)
155 if (!initted) return 0;
156 if ((taspectRatio != ASPECT4X3) && (taspectRatio != ASPECT16X9)) return 0;
157 aspectRatio = taspectRatio;
159 if (ioctl(fdVideo, AV_SET_VID_RATIO, aspectRatio) != 0) return 0;
160 // if (!setMode(mode)) return 0;
164 int Video::setMode(UCHAR tmode)
166 if (!initted) return 0;
168 if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH)
169 && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0;
172 if (ioctl(fdVideo, AV_SET_VID_MODE, mode) != 0) return 0;
174 // int a = ioctl(fdVideo, AV_SET_VID_MODE, mode);
175 // printf("Mode requested: %i, result: %i\n", mode, a);
186 // return ioctl(fdVideo, AV_SET_VID_STC, &stc);
199 int Video::signalOff()
201 if (ioctl(fdVideo, AV_SET_VID_DENC, 0) != 0) return 0;
205 int Video::signalOn()
207 if (ioctl(fdVideo, AV_SET_VID_DENC, 1) != 0) return 0;
211 int Video::setSource()
213 if (!initted) return 0;
215 // What does this do...
216 if (ioctl(fdVideo, AV_SET_VID_SRC, 1) != 0) return 0;
220 int Video::setPosition(int x, int y)
222 if (!initted) return 0;
224 vid_pos_regs_t pos_d;
249 pos_d.y = 100; // Top left X
250 pos_d.x = 50; // Top left Y
258 if (ioctl(fdVideo, AV_SET_VID_POSITION, &pos_d) != 0) return 0;
264 if (!initted) return 0;
266 if (ioctl(fdVideo, AV_SET_VID_SYNC, 2) != 0) return 0;
272 if (!initted) return 0;
274 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
280 if (!initted) return 0;
282 if (ioctl(fdVideo, AV_SET_VID_STOP, 0) != 0) return 0;
288 if (!initted) return 0;
290 if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0;
296 if (!initted) return 0;
298 if (ioctl(fdVideo, AV_SET_VID_PAUSE, 0) != 0) return 0;
302 int Video::unPause() // FIXME get rid - same as play!!
304 if (!initted) return 0;
305 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
309 int Video::fastForward()
311 if (!initted) return 0;
313 if (ioctl(fdVideo, AV_SET_VID_FFWD, 1) != 0) return 0;
317 int Video::unFastForward()
319 if (!initted) return 0;
321 // if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0; // don't need this.
323 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
327 int Video::attachFrameBuffer()
329 if (!initted) return 0;
331 if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0;
335 int Video::blank(void)
337 if (ioctl(fdVideo, AV_SET_VID_FB, 1) != 0) return 0;
338 if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0;
344 if (!initted) return 0;
349 UCHAR Video::getFormat()
354 UINT Video::getScreenWidth()
359 UINT Video::getScreenHeight()
365 UCHAR Video::getTVsize()