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;
44 Video* Video::getInstance()
49 int Video::init(UCHAR format, UCHAR connection, UCHAR aspectRatio, UCHAR mode)
51 if (initted) return 0;
54 // if ((fdVideo = open("/dev/vdec_dev", O_RDWR | O_NONBLOCK)) < 0) return 0;
55 if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0;
57 this->format = format;
58 this->connection = connection;
59 this->aspectRatio = aspectRatio;
74 int Video::initAllParams()
76 return (setFormat(format) && setConnection(connection) &&
77 setAspectRatio(aspectRatio) && setMode(mode) && setSource());
82 if (!initted) return 0;
88 int Video::write(char *buf, int len)
90 return 1;//write(fdVideo, buf, len);
93 int Video::setFormat(UCHAR format)
95 if (!initted) return 0;
96 if ((format != PAL) && (format != NTSC)) return 0;
98 if (ioctl(fdVideo, AV_SET_VID_DISP_FMT, format) != 0) return 0;
99 this->format = format;
103 int Video::setConnection(UCHAR connection)
105 if (!initted) return 0;
106 if ((connection != SCART) && (connection != COMPOSITE) && (connection != SVIDEO)) return 0;
108 if (ioctl(fdVideo, AV_SET_VID_OUTPUT, connection) != 0) return 0;
109 this->connection = connection;
113 int Video::setAspectRatio(UCHAR aspectRatio)
115 if (!initted) return 0;
116 if ((aspectRatio != ASPECT4X3) && (aspectRatio != ASPECT16X9)) return 0;
118 if (ioctl(fdVideo, AV_SET_VID_RATIO, aspectRatio) != 0) return 0;
119 this->aspectRatio = aspectRatio;
123 int Video::setMode(UCHAR mode)
125 if (!initted) return 0;
127 if ((mode != NORMAL) && (mode != LETTERBOX) && (mode != UNKNOWN2) && (mode != QUARTER) && (mode != EIGHTH)
128 && (mode != ZOOM) && (mode != UNKNOWN6)) return 0;
132 if (ioctl(fdVideo, AV_SET_VID_MODE, mode) != 0) return 0;
142 // return ioctl(fdVideo, AV_SET_VID_STC, &stc);
156 int Video::signalOff()
158 if (ioctl(fdVideo, AV_SET_VID_DENC, 0) != 0) return 0;
162 int Video::signalOn()
164 if (ioctl(fdVideo, AV_SET_VID_DENC, 1) != 0) return 0;
168 int Video::setSource()
170 if (!initted) return 0;
172 // What does this do...
173 if (ioctl(fdVideo, AV_SET_VID_SRC, 1) != 0) return 0;
177 int Video::setPosition(int x, int y)
179 if (!initted) return 0;
181 vid_pos_regs_t pos_d;
206 pos_d.y = 100; // Top left X
207 pos_d.x = 50; // Top left Y
215 if (ioctl(fdVideo, AV_SET_VID_POSITION, &pos_d) != 0) return 0;
221 if (!initted) return 0;
223 if (ioctl(fdVideo, AV_SET_VID_SYNC, 2) != 0) return 0;
229 if (!initted) return 0;
231 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
237 if (!initted) return 0;
239 if (ioctl(fdVideo, AV_SET_VID_STOP, 0) != 0) return 0;
245 if (!initted) return 0;
247 if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0;
253 if (!initted) return 0;
255 if (ioctl(fdVideo, AV_SET_VID_PAUSE, 0) != 0) return 0;
259 int Video::unPause() // FIXME get rid - same as play!!
261 if (!initted) return 0;
262 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
266 int Video::fastForward()
268 if (!initted) return 0;
270 if (ioctl(fdVideo, AV_SET_VID_FFWD, 1) != 0) return 0;
274 int Video::unFastForward()
276 if (!initted) return 0;
278 // if (ioctl(fdVideo, AV_SET_VID_RESET, 0x11) != 0) return 0; // don't need this.
280 if (ioctl(fdVideo, AV_SET_VID_PLAY, 0) != 0) return 0;
284 int Video::attachFrameBuffer()
286 if (!initted) return 0;
288 if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0;
292 int Video::blank(void)
294 if (ioctl(fdVideo, AV_SET_VID_FB, 1) != 0) return 0;
295 if (ioctl(fdVideo, AV_SET_VID_FB, 0) != 0) return 0;
301 if (!initted) return 0;