~ubuntu-branches/ubuntu/natty/lirc/natty

« back to all changes in this revision

Viewing changes to daemons/hw_iguanaIR.c

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello, Jeremy Yoder, Mario Limonciello
  • Date: 2009-10-12 21:16:10 UTC
  • mfrom: (1.2.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20091012211610-z63bnon17ahmxgd1
Tags: 0.8.6-0ubuntu1
[ Jeremy Yoder ]
* Update to LIRC 0.8.6 release. (LP: #432678)
  - added support for ENE KB3926 revision B/C/D (ENE0100) CIR port
    (found on some notebooks, e.g: Acer Aspire 5720G, HP Pavilion dv5)
    (Maxim Levitsky)
  - New parameter for lircd: --repeat-max
  - merged 1st-gen mceusb device support into lirc_mceusb2,
    renamed lirc_mceusb2 to lirc_mceusb
  - added support for putting iMON receviers into MCE/RC6 mode
  - added input subsystem mouse device support to iMON driver
  - improved iMON driver to handle dual-interface iMON devices
    via a single lirc device, reducing configuration complexity
  - added support for more iMON devices, including proper support
    for touchscreen iMON devices (Rene Harder)
  - improved iMON driver including touchscreen support
  - Linux input support added to lircmd
  - added support for IT8720 CIR port
  - added support for XMP protocol
* Cleanup more_remotes.hwdb
* TODO:  Make changes to the "lircd.conf.atiusb" and
  "lircd.conf.hauppauge" files PATCHES instead of duplicates
* TODO:  Submit "lircd.conf.atiusb" and
  "lircd.conf.hauppauge" file patches upstream again
* Changed lirc init script to create socket in /var/run/lirc/lircd
  as is the new default, but also create a symlink /dev/lircd
  to point to it.  This makes all clients happy, old and new.
* Fix bug in dkms.conf.in, forgot to increment array number
  when adding ene0100 driver.
* Added the extra "Debian-only" remotes and transmitters back
  in, but in a different way.  I created a subdirectory 
  "debian/extras" and copy that to /usr/share/lirc/extras.
  This avoids patching the source.
  NOTE: CONFIG FILES IN BOTH LOCATIONS WILL USE THE "extras"
  VERSION.  DUPLICATE LINES IN lirc.hwdb AND extras/remotes.hwdb
  WILL USE THE extras/remotes.hwdb VERSION.  TRY TO AVOID THIS.
* Added support to build new ene0100 driver
* Update debian/lircd.init.d to reflect new default
  PID location in /var/run/lirc
* Update debian/lircd.init.d to force socket to /dev/lircd
  rather than the new default of /var/run/lirc/lircd
* Add support for new lirc-extras package to
  debian/lirc.postinst
* Remove /etc/lircd.conf link to /etc/lirc since
  0.8.6 defaults to /etc/lirc/lircd.conf now
* Drop 04_man_pages patch, included in upstream
* Drop 16_lirc-gpio in favor of a sed line in debian/rules
* Drop 28_irrecord_resume_support - Doesn't work
  according to upstream
* Drop 36_remove_extra_tekram in favor of a minor
  tweak to debian/lirc.postinst to ignore duplicates
* Drop extra remote control/transmitter patches, move to lirc-extras:
  - 21_atiusb
  - 22_hauppauge_novat_500
  - 23_remove_md8800
  - 24_freecom_dvbt
  - 26_transmitter_lircd.conf
  - 30_medion_md1_remote
  - 31_hauppauge_hvr_1100
  - 32_radioshack_15_2116_remote
  - 33_asus_mycinema_remote
  - 34_nebula_digitaltv_remote
  - 35_general_deviniput
  - 37_msi_tv_anywhere
  - 38_encore_enltv
* Cleaned up a few lintian warnings

[ Mario Limonciello ]
* lirc.init.d:
  - Merge a bunch of whitespace cleanup from debian.
* control:
  - Merge whitespace cleanup from debian.
  - Drop breaks on udev.  We don't have any older version of udev in karmic.
* copyright:
  - Sync from debian.
* watch:
  - Sync from debian.
* links:
  - Don't link to a transmitterdb, this should be provided by lirc-extras.
* rules:
  - Install extra changelog, as mentioned in debian's debian/rules.
* dkms.conf.in:
  - Drop bashisms. (LP: #445175)
* lirc.postinst:
  - On upgrades from earlier versions, require the user to reconfigure
    their remote and transmitter.
* lirc-modules-source.postinst:
  - Update to use the DKMS common postinst template.
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <stdio.h>
19
19
#include <stdint.h>
20
20
#include <errno.h>
 
21
#if defined __APPLE__
 
22
#include <sys/wait.h>
 
23
#include <sys/ioctl.h>
 
24
#else
21
25
#include <wait.h>
 
26
#endif
22
27
 
23
28
#include "lircd.h"
24
29
#include "ir_remote_types.h"
39
44
        recvDone = 1;
40
45
}
41
46
 
42
 
static void recv_loop(int fd)
 
47
static void recv_loop(int fd, int notify)
43
48
{
44
49
        int conn;
45
50
 
50
55
        signal(SIGHUP, SIG_IGN);
51
56
        signal(SIGALRM, SIG_IGN);
52
57
 
 
58
        /* notify parent by closing notify */
 
59
        close(notify);
 
60
 
53
61
        conn = iguanaConnect(hw.device);
54
62
        if (conn != -1)
55
63
        {
61
69
                        while(! recvDone)
62
70
                        {
63
71
                                /* read from device */
64
 
                                response = iguanaReadResponse(conn, 1000);
 
72
                                do
 
73
                                {
 
74
                                        response = iguanaReadResponse(conn, 1000);
 
75
                                }
 
76
                                while (!recvDone &&
 
77
                                        ((response == NULL && errno == ETIMEDOUT)
 
78
                                        || (iguanaResponseIsError(response) && errno == ETIMEDOUT)));
65
79
 
66
80
                                if (iguanaResponseIsError(response))
67
81
                                {
143
157
        }
144
158
        else
145
159
        {
146
 
                hw.fd = recv_pipe[0];
 
160
                int notify[2];
147
161
 
148
 
                child = fork();
149
 
                if (child == -1)
150
 
                {
151
 
                        logprintf(LOG_ERR, "couldn't fork child process: %s", strerror(errno));
152
 
                }
153
 
                else if (child == 0)
154
 
                {
 
162
                if (pipe(notify) != 0)
 
163
                {
 
164
                        logprintf(LOG_ERR, "couldn't open pipe: %s", strerror(errno));
155
165
                        close(recv_pipe[0]);
156
 
                        recv_loop(recv_pipe[1]);
157
 
                        _exit(0);
158
 
                }
159
 
                else
160
 
                {
161
166
                        close(recv_pipe[1]);
162
 
                        sendConn = iguanaConnect(hw.device);
163
 
                        if (sendConn == -1)
164
 
                                logprintf(LOG_ERR, "couldn't open connection to iguanaIR daemon: %s", strerror(errno));
 
167
                }
 
168
                else
 
169
                {
 
170
                        hw.fd = recv_pipe[0];
 
171
 
 
172
                        child = fork();
 
173
                        if (child == -1)
 
174
                        {
 
175
                                logprintf(LOG_ERR, "couldn't fork child process: %s", strerror(errno));
 
176
                        }
 
177
                        else if (child == 0)
 
178
                        {
 
179
                                close(recv_pipe[0]);
 
180
                                close(notify[0]);
 
181
                                recv_loop(recv_pipe[1], notify[1]);
 
182
                                _exit(0);
 
183
                        }
165
184
                        else
166
 
                                retval = 1;
 
185
                        {
 
186
                                int dummy;
 
187
                                close(recv_pipe[1]);
 
188
                                close(notify[1]);
 
189
                                /* make sure child has set its signal handler to avoid race with iguana_deinit() */
 
190
                                read(notify[0], &dummy, 1);
 
191
                                close(notify[0]);
 
192
                                sendConn = iguanaConnect(hw.device);
 
193
                                if (sendConn == -1)
 
194
                                        logprintf(LOG_ERR, "couldn't open connection to iguanaIR daemon: %s", strerror(errno));
 
195
                                else
 
196
                                        retval = 1;
 
197
                        }
167
198
                }
168
199
        }
169
200
 
170
201
        return retval;
171
202
}
172
203
 
 
204
static pid_t dowaitpid(pid_t pid, int *stat_loc, int options)
 
205
{
 
206
        pid_t retval;
 
207
 
 
208
        do
 
209
        {
 
210
                retval = waitpid(pid, stat_loc, options);
 
211
        }
 
212
        while (retval == (pid_t) -1 && errno == EINTR);
 
213
 
 
214
        return retval;
 
215
}
 
216
 
173
217
static int iguana_deinit()
174
218
{
175
 
        int retval = 1;
176
 
 
177
219
        /* close the connection to the iguana daemon */
178
220
        if (sendConn != -1)
179
221
        {
183
225
 
184
226
        /* signal the child process to exit */
185
227
        if (child > 0 && (kill(child, SIGTERM) == -1 ||
186
 
                          waitpid(child, NULL, 0) != 0))
 
228
                          dowaitpid(child, NULL, 0) != (pid_t) -1))
187
229
        {
188
 
                retval = 0;
189
230
                child = 0;
190
231
        }
191
232
 
193
234
        close(hw.fd);
194
235
        hw.fd = -1;
195
236
 
196
 
        return retval;
 
237
        return child == 0;
197
238
}
198
239
 
199
240
static char *iguana_rec(struct ir_remote *remotes)
314
355
static lirc_t readdata(lirc_t timeout)
315
356
{
316
357
        lirc_t code = 0;
317
 
        struct timeval tv = {0, timeout};
 
358
        struct timeval tv = {timeout/1000000, timeout%1000000};
318
359
        fd_set fds;
319
360
 
320
361
        FD_ZERO(&fds);