annotate simpletv.c @ 6:f0cbbe964629

XShmDetach() both cases.
author darius
date Tue, 28 Jun 2005 13:14:03 +0000
parents 8b6b46a1261d
children 210d197c77f9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
1 /* Capture and store a 24 bit RGB image as a PPM file */
769b155a34f9 Initial revision
darius
parents:
diff changeset
2 /* Copyright (c) 2000 Randall Hopper
769b155a34f9 Initial revision
darius
parents:
diff changeset
3 *
769b155a34f9 Initial revision
darius
parents:
diff changeset
4 * Based on a grab.c from Roger Hardiman, which was
769b155a34f9 Initial revision
darius
parents:
diff changeset
5 * based on an original program by Mark Tinguely and Jim Lowe .
769b155a34f9 Initial revision
darius
parents:
diff changeset
6 *
769b155a34f9 Initial revision
darius
parents:
diff changeset
7 * All rights reserved.
769b155a34f9 Initial revision
darius
parents:
diff changeset
8 *
769b155a34f9 Initial revision
darius
parents:
diff changeset
9 * Redistribution and use in source and binary forms, with or without
769b155a34f9 Initial revision
darius
parents:
diff changeset
10 * modification, are permitted provided that the following conditions
769b155a34f9 Initial revision
darius
parents:
diff changeset
11 * are met:
769b155a34f9 Initial revision
darius
parents:
diff changeset
12 * 1. Redistributions of source code must retain the above copyright
769b155a34f9 Initial revision
darius
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer.
769b155a34f9 Initial revision
darius
parents:
diff changeset
14 * 2. Redistributions in binary form must reproduce the above copyright
769b155a34f9 Initial revision
darius
parents:
diff changeset
15 * notice, this list of conditions and the following disclaimer in the
769b155a34f9 Initial revision
darius
parents:
diff changeset
16 * documentation and/or other materials provided with the distribution.
769b155a34f9 Initial revision
darius
parents:
diff changeset
17 * 3. All advertising materials mentioning features or use of this software
769b155a34f9 Initial revision
darius
parents:
diff changeset
18 * must display the following acknowledgement:
769b155a34f9 Initial revision
darius
parents:
diff changeset
19 * This product includes software developed by Mark Tinguely and Jim Lowe
769b155a34f9 Initial revision
darius
parents:
diff changeset
20 * 4. The name of the author may not be used to endorse or promote products
769b155a34f9 Initial revision
darius
parents:
diff changeset
21 * derived from this software without specific prior written permission.
769b155a34f9 Initial revision
darius
parents:
diff changeset
22 *
769b155a34f9 Initial revision
darius
parents:
diff changeset
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
769b155a34f9 Initial revision
darius
parents:
diff changeset
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
769b155a34f9 Initial revision
darius
parents:
diff changeset
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
769b155a34f9 Initial revision
darius
parents:
diff changeset
26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
769b155a34f9 Initial revision
darius
parents:
diff changeset
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
769b155a34f9 Initial revision
darius
parents:
diff changeset
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
769b155a34f9 Initial revision
darius
parents:
diff changeset
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
769b155a34f9 Initial revision
darius
parents:
diff changeset
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
769b155a34f9 Initial revision
darius
parents:
diff changeset
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
769b155a34f9 Initial revision
darius
parents:
diff changeset
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
769b155a34f9 Initial revision
darius
parents:
diff changeset
33 * POSSIBILITY OF SUCH DAMAGE.
769b155a34f9 Initial revision
darius
parents:
diff changeset
34 */
769b155a34f9 Initial revision
darius
parents:
diff changeset
35
769b155a34f9 Initial revision
darius
parents:
diff changeset
36 #include <assert.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
37 #include <stdio.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
38 #include <unistd.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
39 #include <string.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
40 #include <stdlib.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
41 #include <errno.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
42 #include <sys/types.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
43 #include <poll.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
44 #include <sys/mman.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
45 #include <sys/fcntl.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
46 #include <sys/time.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
47 #include <libgen.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
48 #include <sys/soundcard.h>
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
49 #include <dev/bktr/ioctl_bt848.h>
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
50 #include <dev/bktr/ioctl_meteor.h>
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
51 #include <machine/param.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
52 #include <sys/types.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
53 #include <sys/ipc.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
54 #include <sys/shm.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
55 #include <X11/Xlib.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
56 #include <X11/Xutil.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
57 #include <X11/extensions/XShm.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
58 #include <X11/extensions/Xvlib.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
59 #ifndef USE_XVIMAGES
769b155a34f9 Initial revision
darius
parents:
diff changeset
60 #include "Hermes/Hermes.h"
769b155a34f9 Initial revision
darius
parents:
diff changeset
61 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
62
769b155a34f9 Initial revision
darius
parents:
diff changeset
63 #include <lirc/lirc_client.h>
769b155a34f9 Initial revision
darius
parents:
diff changeset
64
769b155a34f9 Initial revision
darius
parents:
diff changeset
65 /* Some BT848/BT878 cards have gain control hardware which takes
769b155a34f9 Initial revision
darius
parents:
diff changeset
66 1 or 2 seconds to settle. If you get a washed out / too bright
769b155a34f9 Initial revision
darius
parents:
diff changeset
67 image, change the GRABBER_SETTLE_TIME from 0 to either 1 or 2
769b155a34f9 Initial revision
darius
parents:
diff changeset
68 */
769b155a34f9 Initial revision
darius
parents:
diff changeset
69 /*#define GRABBER_SETTLE_TIME 10*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
70 #define GRABBER_SETTLE_TIME 0
769b155a34f9 Initial revision
darius
parents:
diff changeset
71
769b155a34f9 Initial revision
darius
parents:
diff changeset
72
769b155a34f9 Initial revision
darius
parents:
diff changeset
73 #define PAL 1
769b155a34f9 Initial revision
darius
parents:
diff changeset
74 #define NTSC 2
769b155a34f9 Initial revision
darius
parents:
diff changeset
75
769b155a34f9 Initial revision
darius
parents:
diff changeset
76 /* PAL is 768 x 576. NTSC is 640 x 480 */
769b155a34f9 Initial revision
darius
parents:
diff changeset
77 #define PAL_HEIGHT 576
769b155a34f9 Initial revision
darius
parents:
diff changeset
78 #define NTSC_HEIGHT 480
769b155a34f9 Initial revision
darius
parents:
diff changeset
79
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
80 int bktr_fd;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
81 int tuner_fd;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
82 unsigned char *bktr_buffer;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
83 #if 1
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
84 int width = 320;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
85 int height = 240;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
86 #else
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
87 int width = 640;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
88 int height = 480;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
89 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
90
769b155a34f9 Initial revision
darius
parents:
diff changeset
91 #ifndef USE_XVIMAGES
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
92 static XImage *rgb_image;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
93 static Pixmap pmap;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
94 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
95 static XShmSegmentInfo shminfo;
769b155a34f9 Initial revision
darius
parents:
diff changeset
96 static Display *disp;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
97 static Window win;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
98 static Visual *vis;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
99 static int scr;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
100 static GC gc;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
101 static int depth;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
102 static Colormap cmap;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
103 static XVisualInfo *vi;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
104 static int bits_per_pixel;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
105 static XvImage *yuv_image;
769b155a34f9 Initial revision
darius
parents:
diff changeset
106 static XvAdaptorInfo *xv_adaptors;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
107 static int xv_num_adaptors;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
108 static int xv_adaptor;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
109 static int xv_format_id;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
110
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
111 static int channel;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
112
769b155a34f9 Initial revision
darius
parents:
diff changeset
113 #define DO_IOCTL_GERR(str) fprintf(stderr, "ioctl(%s) failed: %s\n", \
769b155a34f9 Initial revision
darius
parents:
diff changeset
114 str, strerror(errno) )
769b155a34f9 Initial revision
darius
parents:
diff changeset
115 #define DO_IOCTL_SERR(str,arg) fprintf(stderr, "ioctl(%s, %ld) failed: %s\n",\
769b155a34f9 Initial revision
darius
parents:
diff changeset
116 str, (long)arg, strerror(errno) )
769b155a34f9 Initial revision
darius
parents:
diff changeset
117 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
118
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
119 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
120 Close() {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
121 close(tuner_fd);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
122 close(bktr_fd);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
123 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
124
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
125 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
126 Open() {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
127 struct meteor_geomet geo;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
128 int buffer_size, format, source, c;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
129 char *device_name;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
130
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
131 format = PAL; /* default value */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
132 source = 1; /* default value */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
133 device_name = "/dev/bktr0"; /* default value */
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
134
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
135 /* Open the Meteor or Bt848/Bt878 grabber */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
136 if ((bktr_fd = open(device_name, O_RDONLY)) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
137 printf("open failed: %d\n", errno);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
138 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
139 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
140 if ((tuner_fd = open("/dev/tuner0", O_RDONLY)) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
141 printf("open failed: %d\n", errno);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
142 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
143 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
144 /* set up the capture type and size */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
145 geo.rows = height;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
146 geo.columns = width;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
147 geo.frames = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
148 #ifdef USE_XVIMAGES
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
149 /* Should be YUV_12, but 422 actually gives a synced picture. Though */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
150 geo.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
151 #else
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
152 geo.oformat = METEOR_GEO_RGB24;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
153 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
154
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
155 /* switch from interlaced capture to single field capture if */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
156 /* the grab height is less than half the normal TV height */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
157 /* this gives better quality captures when the object in the TV */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
158 /* picture is moving */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
159 if ((format == PAL) && (height <= (PAL_HEIGHT / 2)))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
160 geo.oformat |= METEOR_GEO_ODD_ONLY;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
161 if ((format == NTSC) && (height <= (NTSC_HEIGHT / 2)))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
162 geo.oformat |= METEOR_GEO_ODD_ONLY;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
163
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
164 if (ioctl(bktr_fd, METEORSETGEO, &geo) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
165 printf("METEORSETGEO ioctl failed: %d\n", errno);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
166 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
167 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
168 /* Select PAL or NTSC */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
169 switch (format) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
170 case PAL:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
171 c = METEOR_FMT_PAL;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
172 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
173 case NTSC:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
174 c = METEOR_FMT_NTSC;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
175 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
176 default:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
177 c = METEOR_FMT_NTSC;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
178 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
179 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
180
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
181 c = BT848_IFORM_F_PALBDGHI;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
182 if (ioctl(bktr_fd, BT848SFMT, &c) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
183 DO_IOCTL_SERR("BT848SFMT", c);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
184 return;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
185 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
186 c = AUDIO_TUNER;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
187 if (ioctl(tuner_fd, BT848_SAUDIO, &c) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
188 DO_IOCTL_SERR("BT848SFMT", c);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
189 return;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
190 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
191 c = CHNLSET_AUSTRALIA;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
192 if (ioctl(tuner_fd, TVTUNER_SETTYPE, &c) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
193 DO_IOCTL_SERR("TVTUNER_SETTYPE", c);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
194 return;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
195 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
196 if (ioctl(tuner_fd, TVTUNER_SETCHNL, &channel) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
197 DO_IOCTL_SERR("TVTUNER_SETCHNL", channel);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
198 return;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
199 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
200 /* Select the Video Source */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
201 /* Video In, Tuner, S-Video */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
202 switch (source) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
203 case 0:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
204 c = METEOR_INPUT_DEV0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
205 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
206 case 1:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
207 c = METEOR_INPUT_DEV1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
208 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
209 case 2:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
210 c = METEOR_INPUT_DEV2;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
211 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
212 case 3:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
213 c = METEOR_INPUT_DEV3;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
214 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
215 default:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
216 c = METEOR_INPUT_DEV0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
217 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
218 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
219
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
220 printf("Input - %x\n", c);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
221 if (ioctl(bktr_fd, METEORSINPUT, &c) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
222 printf("ioctl failed: %d\n", errno);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
223 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
224 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
225 /* Use mmap to Map the drivers grab buffer */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
226 buffer_size = width * height * 4; /* R,G,B,spare */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
227 bktr_buffer = (unsigned char *)mmap((caddr_t) 0, buffer_size, PROT_READ,
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
228 MAP_SHARED, bktr_fd, (off_t) 0);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
229
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
230 if (bktr_buffer == (unsigned char *)MAP_FAILED)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
231 exit(1);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
232
769b155a34f9 Initial revision
darius
parents:
diff changeset
233
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
234 /* We may need to wait for a short time to allow the grabber */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
235 /* brightness to settle down */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
236 sleep(GRABBER_SETTLE_TIME);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
237 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
238
769b155a34f9 Initial revision
darius
parents:
diff changeset
239 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
240
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
241 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
242 Capture() {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
243 int c;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
244
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
245 /* Perform a single frame capture */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
246 c = METEOR_CAP_SINGLE;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
247 ioctl(bktr_fd, METEORCAPTUR, &c);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
248 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
249
769b155a34f9 Initial revision
darius
parents:
diff changeset
250 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
251
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
252 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
253 SaveImage() {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
254 unsigned char *line_buffer;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
255 int o , w, h;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
256 unsigned char *p;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
257 unsigned char header[30];
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
258 char *filename = "t.ppm" /* argv[3] */ ;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
259
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
260 /* Create the output file */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
261 if ((o = open(filename, O_WRONLY | O_CREAT, 0644)) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
262 printf("ppm open failed: %d\n", errno);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
263 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
264 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
265 /* make PPM header and save to file */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
266 sprintf(header, "P6\n%d\n%d\n255\n", width, height);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
267 write(o, header, strlen(header));
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
268
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
269 /* save the RGB data to PPM file */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
270 /* save this one line at a time */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
271 line_buffer = (unsigned char *)malloc(width * 3 * sizeof(unsigned char));
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
272 p = bktr_buffer;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
273 for (h = 0; h < height; h++) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
274 for (w = 0; w < width; w++) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
275 line_buffer[(w * 3) + 2] = *p++; /* blue */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
276 line_buffer[(w * 3) + 1] = *p++; /* green */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
277 line_buffer[(w * 3) + 0] = *p++; /* red */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
278 p++; /* NULL byte */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
279 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
280 write(o, line_buffer, width * 3);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
281 }
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
282 close(o);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
283 free(line_buffer);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
284 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
285
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
286 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
287 X_ShowCursor(void) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
288 XDefineCursor(disp, win, 0);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
289 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
290
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
291 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
292 X_HideCursor(void) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
293 Cursor no_ptr;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
294 Pixmap bm_no;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
295 XColor black , dummy;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
296 Colormap colormap;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
297 static unsigned char bm_no_data[] = {0, 0, 0, 0, 0, 0, 0, 0};
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
298
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
299 colormap = DefaultColormap(disp, DefaultScreen(disp));
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
300 XAllocNamedColor(disp, colormap, "black", &black, &dummy);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
301 bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8, 8);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
302 no_ptr = XCreatePixmapCursor(disp, bm_no, bm_no, &black, &black, 0, 0);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
303
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
304 XDefineCursor(disp, win, no_ptr);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
305 XFreeCursor(disp, no_ptr);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
306 if (bm_no != None)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
307 XFreePixmap(disp, bm_no);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
308
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
309 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
310
769b155a34f9 Initial revision
darius
parents:
diff changeset
311 /*
769b155a34f9 Initial revision
darius
parents:
diff changeset
312 * Sends the EWMH fullscreen state event.
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
313 *
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
314 * action: could be on of _NET_WM_STATE_REMOVE -- remove state
769b155a34f9 Initial revision
darius
parents:
diff changeset
315 * _NET_WM_STATE_ADD -- add state
769b155a34f9 Initial revision
darius
parents:
diff changeset
316 * _NET_WM_STATE_TOGGLE -- toggle
769b155a34f9 Initial revision
darius
parents:
diff changeset
317 */
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
318 #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
319 #define _NET_WM_STATE_ADD 1 /* add/set property */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
320 #define _NET_WM_STATE_TOGGLE 2 /* toggle property */
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
321 void
769b155a34f9 Initial revision
darius
parents:
diff changeset
322 vo_x11_ewmh_fullscreen(int action) {
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
323 XEvent xev;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
324
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
325 assert(action == _NET_WM_STATE_REMOVE ||
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
326 action == _NET_WM_STATE_ADD || action == _NET_WM_STATE_TOGGLE);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
327
769b155a34f9 Initial revision
darius
parents:
diff changeset
328
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
329 /* init X event structure for _NET_WM_FULLSCREEN client msg */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
330 xev.xclient.type = ClientMessage;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
331 xev.xclient.serial = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
332 xev.xclient.send_event = True;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
333 xev.xclient.message_type = XInternAtom(disp, "_NET_WM_STATE", False);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
334 xev.xclient.window = win;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
335 xev.xclient.format = 32;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
336 xev.xclient.data.l[0] = action;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
337 xev.xclient.data.l[1] = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
338 xev.xclient.data.l[2] = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
339 xev.xclient.data.l[3] = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
340 xev.xclient.data.l[4] = 0;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
341
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
342 /* finally send that damn thing */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
343 if (!XSendEvent(disp, DefaultRootWindow(disp), False,
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
344 SubstructureRedirectMask | SubstructureNotifyMask,
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
345 &xev)) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
346 fprintf(stderr, "Failed to send fullscreen command\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
347 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
348 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
349
769b155a34f9 Initial revision
darius
parents:
diff changeset
350
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
351 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
352 X_Setup(int w, int h) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
353 XGCValues gcvals;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
354 Window root;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
355 XVisualInfo vinfo_pref;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
356 int num_vis;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
357 XPixmapFormatValues *pf;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
358 int num_pf , pfi, i, j;
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
359 XSizeHints sz_hint;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
360
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
361 disp = XOpenDisplay(NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
362 if (!disp) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
363 fprintf(stderr, "X-Error: unable to connect to display\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
364 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
365 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
366 XSynchronize(disp, True);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
367
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
368 scr = DefaultScreen(disp);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
369 vis = DefaultVisual(disp, scr);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
370 root = DefaultRootWindow(disp);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
371 depth = DefaultDepth(disp, scr);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
372
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
373 vinfo_pref.screen = scr;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
374 vinfo_pref.visualid = XVisualIDFromVisual(vis);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
375 vi = XGetVisualInfo(disp, VisualScreenMask | VisualIDMask,
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
376 &vinfo_pref, &num_vis);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
377 assert(num_vis == 1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
378
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
379 win = XCreateSimpleWindow(disp, root, 0, 0, w, h, 0, 0, 0);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
380 gc = XCreateGC(disp, win, (unsigned long)0, &gcvals);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
381 XSetForeground(disp, gc, 0);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
382 XSetBackground(disp, gc, 1);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
383
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
384 XMapWindow(disp, win);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
385 cmap = DefaultColormap(disp, scr);
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
386
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
387 sz_hint.flags = PAspect;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
388 sz_hint.min_aspect.x = width;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
389 sz_hint.min_aspect.y = height;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
390 sz_hint.max_aspect.x = width;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
391 sz_hint.max_aspect.y = height;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
392
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
393 /* set min height/width to 4 to avoid off by one errors */
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
394 sz_hint.min_width = sz_hint.min_height = 4;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
395 sz_hint.flags |= PMinSize;
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
396 XSetWMNormalHints(disp, win, &sz_hint);
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
397
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
398 XSync(disp, False);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
399
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
400 /* Setup with Xv extension */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
401 xv_adaptor = -1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
402 xv_format_id = -1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
403 XvQueryAdaptors(disp, root, &xv_num_adaptors, &xv_adaptors);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
404 for (i = 0; i < xv_num_adaptors; i++) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
405 XvAdaptorInfo *adaptor = &xv_adaptors[i];
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
406 int takes_images;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
407
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
408 takes_images = adaptor->type & (XvInputMask | XvImageMask);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
409 if (takes_images) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
410 XvImageFormatValues *formats;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
411 int num_formats;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
412
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
413 formats = XvListImageFormats(disp, adaptor->base_id, &num_formats);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
414 for (j = 0; j < num_formats; j++)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
415 if (formats[j].type == XvYUV && formats[j].format == XvPlanar &&
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
416 strcmp(formats[j].guid, "YV12") == 0)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
417 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
418 if (j < num_formats) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
419 xv_adaptor = i;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
420 xv_format_id = formats[j].id;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
421 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
422 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
423 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
424 }
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
425 assert(xv_adaptor >= 0);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
426
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
427 /* Create an image to captured frames */
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
428 #ifdef USE_XVIMAGES
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
429 yuv_image = XvShmCreateImage(disp, xv_adaptors[xv_adaptor].base_id,
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
430 xv_format_id, 0, w, h, &shminfo);
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
431 if (!yuv_image)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
432 fprintf(stderr, "X-Error: unable to create XvShm XImage\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
433
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
434 shminfo.shmid = shmget(IPC_PRIVATE, yuv_image->data_size, IPC_CREAT | 0777);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
435 if (shminfo.shmid == -1)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
436 fprintf(stderr, "SharedMemory Error: unable to get identifier\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
437
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
438 shminfo.shmaddr = yuv_image->data = shmat(shminfo.shmid, 0, 0);
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
439 yuv_image->data = shminfo.shmaddr;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
440 #else
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
441 rgb_image = XShmCreateImage(disp, vis, depth, ZPixmap, NULL, &shminfo, w, h);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
442 if (!rgb_image)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
443 fprintf(stderr, "X-Error: unable to create XShm XImage\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
444
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
445 shminfo.shmid = shmget(IPC_PRIVATE,
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
446 rgb_image->bytes_per_line * rgb_image->height,
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
447 IPC_CREAT | 0777);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
448 if (shminfo.shmid == -1)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
449 fprintf(stderr, "SharedMemory Error: unable to get identifier\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
450
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
451 shminfo.shmaddr = rgb_image->data = shmat(shminfo.shmid, 0, 0);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
452 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
453
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
454 if (!XShmAttach(disp, &shminfo))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
455 fprintf(stderr, "X-Error: unable to attach XShm Shared Memory Segment\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
456
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
457 /* Create a pixmap for the window background */
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
458 #ifdef OLD
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
459 pmap = XShmCreatePixmap(disp, win, shminfo.shmaddr, &shminfo, w, h, depth);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
460 if (!pmap)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
461 fprintf(stderr, "Unable to create pixmap\n");
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
462 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
463
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
464 /* Determine bits-per-pixel for pixmaps */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
465 pf = XListPixmapFormats(disp, &num_pf);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
466 assert(pf);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
467 for (pfi = 0; pfi < num_pf; pfi++)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
468 if (pf[pfi].depth == vi->depth)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
469 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
470 assert(pfi < num_pf);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
471 bits_per_pixel = pf[pfi].bits_per_pixel;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
472 XFree(pf);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
473
769b155a34f9 Initial revision
darius
parents:
diff changeset
474 #ifdef OLD
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
475 XSetWindowBackgroundPixmap(disp, win, pmap);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
476 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
477 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
478
769b155a34f9 Initial revision
darius
parents:
diff changeset
479 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
480
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
481 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
482 X_Shutdown() {
6
f0cbbe964629 XShmDetach() both cases.
darius
parents: 5
diff changeset
483 XShmDetach(disp, &shminfo);
5
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
484 #ifdef USE_XVIMAGES
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
485 shmctl(shminfo.shmid, IPC_RMID, 0);
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
486 shmdt(shminfo.shmaddr);
8b6b46a1261d - Move to 5.x+ includes
darius
parents: 3
diff changeset
487 XFree(yuv_image);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
488 #else
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
489 XDestroyImage(rgb_image);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
490 #endif
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
491 shmdt(shminfo.shmaddr);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
492 shmctl(shminfo.shmid, IPC_RMID, 0);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
493 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
494
769b155a34f9 Initial revision
darius
parents:
diff changeset
495
769b155a34f9 Initial revision
darius
parents:
diff changeset
496 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
497
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
498 void
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
499 X_Display(void) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
500 int _w , _h, _d;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
501 Window _dw;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
502
769b155a34f9 Initial revision
darius
parents:
diff changeset
503 #ifdef USE_XVIMAGES
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
504 XGetGeometry(disp, win, &_dw, &_d, &_d, &_w, &_h, &_d, &_d);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
505 XvShmPutImage(disp, xv_adaptors[xv_adaptor].base_id, win,
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
506 gc, yuv_image, 0, 0, yuv_image->width, yuv_image->height,
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
507 0, 0, _w, _h, True);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
508 #else
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
509 XShmPutImage(disp, win, gc, rgb_image, 0, 0, 0, 0,
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
510 rgb_image->width, rgb_image->height, False);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
511 #endif
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
512 XSync(disp, False);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
513 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
514
769b155a34f9 Initial revision
darius
parents:
diff changeset
515 #define CMD_NONE 0
769b155a34f9 Initial revision
darius
parents:
diff changeset
516 #define CMD_CHNUP 1
769b155a34f9 Initial revision
darius
parents:
diff changeset
517 #define CMD_CHNDN 2
769b155a34f9 Initial revision
darius
parents:
diff changeset
518 #define CMD_MUTE 3
769b155a34f9 Initial revision
darius
parents:
diff changeset
519 #define CMD_QUIT 4
769b155a34f9 Initial revision
darius
parents:
diff changeset
520 #define CMD_RELOAD 5
769b155a34f9 Initial revision
darius
parents:
diff changeset
521 #define CMD_CURSOR 6
769b155a34f9 Initial revision
darius
parents:
diff changeset
522 #define CMD_VOLDN 7
769b155a34f9 Initial revision
darius
parents:
diff changeset
523 #define CMD_VOLUP 8
769b155a34f9 Initial revision
darius
parents:
diff changeset
524 #define CMD_FSTOGGLE 9
769b155a34f9 Initial revision
darius
parents:
diff changeset
525
769b155a34f9 Initial revision
darius
parents:
diff changeset
526 /*--------------------------------------------------------------------------*/
769b155a34f9 Initial revision
darius
parents:
diff changeset
527
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
528 int
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
529 main(int argc, char *argv[]) {
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
530 #ifndef USE_XVIMAGES
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
531 HermesHandle conv;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
532 HermesFormat fmt_source, fmt_dest;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
533 #endif
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
534 XEvent e;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
535 char *scratch_buf, *code, *c, *mixerdev;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
536 int frames , channelidx, oldchan, mute, cursor, fd, ret, cmd;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
537 int exitnow , mfd, uselirc, curvol;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
538 struct timeval then, now, diff, lastmove;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
539 float rate;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
540 KeySym key;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
541 char text [255];
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
542 int channellist[] = {2, 7, 9, 10, 28};
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
543 struct lirc_config *config;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
544 struct pollfd fds[1];
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
545
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
546 #define NUMCHANS (sizeof(channellist) / sizeof(channellist[0]))
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
547
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
548 channelidx = mute = cursor = 0;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
549
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
550 oldchan = channel = channellist[channelidx];
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
551
769b155a34f9 Initial revision
darius
parents:
diff changeset
552 #ifndef USE_XVIMAGES
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
553 if (!Hermes_Init()) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
554 printf("Couldn't initialise Hermes!\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
555 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
556 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
557 conv = Hermes_ConverterInstance(HERMES_CONVERT_NORMAL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
558 if (!conv) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
559 printf("Could not obtain converter instance from Hermes!\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
560 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
561 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
562 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
563
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
564 X_Setup(width, height);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
565 XSelectInput(disp, win, KeyReleaseMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
566
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
567 X_HideCursor();
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
568
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
569 /* Open Capture device */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
570 Open();
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
571
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
572 /* Open audio mixer */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
573 mixerdev = "/dev/mixer";
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
574 if ((mfd = open(mixerdev, O_RDWR)) == -1)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
575 fprintf(stderr, "Unable to open %s - %s\n", mixerdev, strerror(errno));
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
576
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
577 /* Talk to LIRC */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
578 if ((fd = lirc_init(basename(argv[0]), 1)) == -1) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
579 fprintf(stderr, "Unable to init lirc client library\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
580 uselirc = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
581 } else {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
582 if (lirc_readconfig(NULL, &config, NULL) != 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
583 fprintf(stderr, "Unable to parse config file\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
584 uselirc = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
585 } else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
586 uselirc = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
587 fds[0].fd = fd;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
588 fds[0].events = POLLRDNORM;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
589 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
590
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
591 #ifndef USE_XVIMAGES
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
592 /* Conversion from and to formats */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
593 fmt_source.indexed = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
594 fmt_source.bits = 32;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
595 fmt_source.r = 0xff0000;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
596 fmt_source.g = 0x00ff00;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
597 fmt_source.b = 0x0000ff;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
598 fmt_source.a = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
599
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
600 fmt_dest.indexed = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
601 fmt_dest.bits = bits_per_pixel;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
602 fmt_dest.r = vi->red_mask;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
603 fmt_dest.g = vi->green_mask;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
604 fmt_dest.b = vi->blue_mask;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
605 fmt_dest.a = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
606 #else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
607 scratch_buf = malloc(width * height);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
608 #endif
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
609
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
610 frames = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
611 gettimeofday(&then, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
612 gettimeofday(&lastmove, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
613
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
614 exitnow = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
615
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
616 /* Capture loop */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
617 while (1) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
618 if (frames == 50) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
619 gettimeofday(&now, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
620 timersub(&now, &then, &diff);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
621
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
622 rate = (float)frames / (float)(diff.tv_usec / 1000000.0 + diff.tv_sec);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
623
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
624 printf("%d frames in %.2f seconds, rate %.2f\n", frames, (float)(diff.tv_usec / 1000000.0) + diff.tv_sec, rate);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
625 gettimeofday(&then, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
626 frames = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
627 XResetScreenSaver(disp);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
628 }
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
629 frames++;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
630
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
631 timersub(&now, &lastmove, &diff);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
632 if (((float)diff.tv_usec / 1000000.0 + (float)diff.tv_sec) > 2.0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
633 if (cursor) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
634 X_HideCursor();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
635 cursor = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
636 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
637 } else {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
638 if (!cursor) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
639 X_ShowCursor();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
640 cursor = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
641 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
642 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
643
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
644 if (XCheckMaskEvent(disp, PointerMotionMask, &e) && e.type == MotionNotify) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
645 gettimeofday(&lastmove, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
646 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
647 cmd = CMD_NONE;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
648
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
649 if (XCheckMaskEvent(disp, ButtonReleaseMask, &e)) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
650 printf("e.type = %d\n", e.type);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
651 cmd = CMD_MUTE;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
652 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
653 if (XCheckMaskEvent(disp, KeyReleaseMask, &e) && e.type == KeyRelease) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
654 gettimeofday(&lastmove, NULL);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
655
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
656 XLookupString(&e.xkey, text, 255, &key, 0);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
657 printf("Press - %c\n", text[0]);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
658
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
659 switch (text[0]) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
660 case 'q':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
661 cmd = CMD_QUIT;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
662 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
663
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
664 case '=':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
665 case '+':
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
666 cmd = CMD_CHNUP;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
667 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
668
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
669 case '-':
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
670 cmd = CMD_CHNDN;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
671 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
672
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
673 case 'h':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
674 cmd = CMD_CURSOR;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
675 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
676
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
677 case 'm':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
678 cmd = CMD_MUTE;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
679 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
680
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
681 case 'r':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
682 cmd = CMD_RELOAD;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
683 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
684
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
685 case ',':
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
686 cmd = CMD_VOLDN;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
687 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
688
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
689 case '.':
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
690 cmd = CMD_VOLUP;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
691 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
692
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
693 case 'f':
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
694 cmd = CMD_FSTOGGLE;
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
695 break;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
696 }
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
697 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
698 /* Poll for IR events */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
699 if (uselirc) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
700 fds[0].revents = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
701
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
702 while (1) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
703 if (poll(fds, 1, 0) == -1) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
704 fprintf(stderr, "Poll failed - %s\n", strerror(errno));
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
705 exit(EXIT_FAILURE);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
706 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
707 if ((fds[0].revents & POLLRDNORM) != 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
708 fprintf(stderr, "Processing IR..\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
709
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
710 if (lirc_nextcode(&code) == 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
711 if (code == NULL)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
712 continue;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
713
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
714 while ((ret = lirc_code2char(config, code, &c)) == 0 &&
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
715 c != NULL) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
716 fprintf(stderr, "Got command \"%s\"\n", c);
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
717
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
718 if (!strcmp(c, "Mute"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
719 cmd = CMD_MUTE;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
720 else if (!strcmp(c, "CH_UP"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
721 cmd = CMD_CHNUP;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
722 else if (!strcmp(c, "CH_DOWN"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
723 cmd = CMD_CHNDN;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
724 else if (!strcmp(c, "Power"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
725 cmd = CMD_QUIT;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
726 else if (!strcmp(c, "VOL_UP"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
727 cmd = CMD_VOLUP;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
728 else if (!strcmp(c, "VOL_DOWN"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
729 cmd = CMD_VOLDN;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
730 else if (!strcmp(c, "AV/TV"))
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
731 cmd = CMD_FSTOGGLE;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
732
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
733 free(code);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
734 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
735 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
736 } else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
737 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
738 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
739 }
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
740 switch (cmd) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
741 case CMD_QUIT:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
742 exitnow = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
743 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
744
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
745 case CMD_CHNUP:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
746 case CMD_CHNDN:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
747 if (cmd == CMD_CHNUP)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
748 channelidx++;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
749 else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
750 channelidx--;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
751
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
752 if (channelidx < 0)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
753 channelidx = NUMCHANS - 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
754 if (channelidx > NUMCHANS - 1)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
755 channelidx = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
756
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
757 channel = channellist[channelidx];
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
758
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
759 printf("Channel - %d\n", channel);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
760 if (oldchan != channel) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
761 oldchan = channel;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
762
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
763 if (ioctl(tuner_fd, TVTUNER_SETCHNL, &channel) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
764 DO_IOCTL_SERR("TVTUNER_SETCHNL", channel);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
765 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
766 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
767 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
768 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
769
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
770 case CMD_MUTE:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
771 if (mute)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
772 mute = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
773 else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
774 mute = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
775
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
776 printf("Mute - %d\n", mute);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
777 if (ioctl(tuner_fd, BT848_SAUDIO, &mute) < 0) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
778 DO_IOCTL_SERR("BT848_SAUDIO", mute);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
779 exit(1);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
780 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
781 break;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
782
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
783 case CMD_CURSOR:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
784 if (cursor) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
785 printf("Cursor hidden\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
786 X_HideCursor();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
787 cursor = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
788 } else {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
789 printf("Cursor revealed\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
790 X_ShowCursor();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
791 cursor = 1;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
792 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
793 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
794
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
795 case CMD_RELOAD:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
796 printf("Reloading\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
797 Close();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
798 Open();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
799 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
800
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
801 case CMD_VOLUP:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
802 case CMD_VOLDN:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
803 if (ioctl(mfd, MIXER_READ(SOUND_MIXER_VOLUME), &curvol) == -1) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
804 fprintf(stderr, "Unable to read current volume - %s\n", strerror(errno));
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
805 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
806 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
807 curvol = curvol & 0x7f;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
808
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
809 if (cmd == CMD_VOLUP)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
810 curvol += 5;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
811 else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
812 curvol -= 5;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
813
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
814 if (curvol < 0)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
815 curvol = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
816 if (curvol > 100)
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
817 curvol = 100;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
818
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
819 printf("Setting volume to %d\n", curvol);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
820 curvol |= curvol << 8;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
821
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
822 if (ioctl(mfd, MIXER_WRITE(SOUND_MIXER_VOLUME), &curvol) == -1) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
823 fprintf(stderr, "Unable to write volume - %s\n", strerror(errno));
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
824 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
825 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
826 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
827
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
828 case CMD_FSTOGGLE:
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
829 vo_x11_ewmh_fullscreen(_NET_WM_STATE_TOGGLE);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
830 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
831
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
832 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
833
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
834 Capture();
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
835
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
836 #ifdef USE_XVIMAGES
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
837 /* bktr's YUV_12 is planar W*H bytes Y, W/2*H/2 bytes U, */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
838 /* W/2*H/2 bytes V. Xv's YV12 is the same with U and V */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
839 /* planes reversed. */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
840 {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
841 int y_off , u_off, v_off;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
842 y_off = 0;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
843 u_off = width * height;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
844 v_off = u_off + width * height / 4;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
845
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
846 assert(yuv_image->data_size == width * height * 3 / 2);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
847 memcpy(yuv_image->data, bktr_buffer, u_off - y_off);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
848 memcpy(yuv_image->data + u_off, bktr_buffer + v_off, v_off - u_off);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
849 memcpy(yuv_image->data + v_off, bktr_buffer + u_off, v_off - u_off);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
850 }
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
851 #else
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
852 /* SaveImage(); */
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
853
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
854 Hermes_ConverterRequest(conv, &fmt_source, &fmt_dest);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
855 Hermes_ConverterCopy(conv, bktr_buffer, 0, 0, width, height, width * 4,
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
856 rgb_image->data, 0, 0, width, height,
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
857 rgb_image->bytes_per_line);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
858 #endif
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
859
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
860 X_Display();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
861 if (exitnow) {
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
862 printf("quitting\n");
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
863 break;
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
864 }
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
865 }
769b155a34f9 Initial revision
darius
parents:
diff changeset
866
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
867 #ifndef USE_XVIMAGES
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
868 Hermes_ConverterReturn(conv);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
869 Hermes_Done();
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
870 #endif
769b155a34f9 Initial revision
darius
parents:
diff changeset
871
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
872 X_Shutdown();
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
873 lirc_freeconfig(config);
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
874 lirc_deinit();
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
875
3
8d7d1680db7d style(9) mostly with
darius
parents: 1
diff changeset
876 return 0;
1
769b155a34f9 Initial revision
darius
parents:
diff changeset
877 }