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

« back to all changes in this revision

Viewing changes to daemons/hw_atilibusb.c

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello
  • Date: 2010-04-02 15:06:19 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100402150619-y1z8c1yqv621a11o
Tags: 0.8.7~pre2-0ubuntu1
* Update to 0.8.7~pre2
  - Fixes issues with lirc on maverick. (LP: #620498)
* Add lirc-in-kernel-ioctls.patch to use ioctls from the kernel for drivers.
* Drop patches upstream now:
  - debian/patches/appleir_repeat_issue.patch
  - debian/patches/hauppauge-tv-card.patch
  - debian/patches/lirc-i2c-2.6.patch
  - debian/patches/lirc_dev-2.6.33.patch
* Add updated-driver-names.patch 
* Refresh patches:
  - debian/patches/02_Makefile.in
  - debian/patches/13-warning-cleanup
* Update extra transmitter and remote databases to not reference atiusb.
* debian/control:
  - Update branches to be owned by ~mythbuntu-dev
* Disable in-kernel-support when starting lircd, and re-enable when
  stopping.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*      $Id: hw_atilibusb.c,v 5.5 2009/07/05 21:29:24 jarodwilson Exp $      */
 
1
/*      $Id: hw_atilibusb.c,v 5.7 2010/04/11 18:50:38 lirc Exp $      */
2
2
 
3
3
/****************************************************************************
4
4
 ** hw_atilibusb.c **********************************************************
57
57
        LIRC_MODE_LIRCCODE,         /* rec_mode */
58
58
        CODE_BYTES * CHAR_BIT,      /* code_length */
59
59
        ati_init,                   /* init_func */
60
 
        NULL,                       /* config_func */
61
60
        ati_deinit,                 /* deinit_func */
62
61
        NULL,                       /* send_func */
63
62
        ati_rec,                    /* rec_func */
107
106
        struct usb_device *usb_dev;
108
107
        int pipe_fd[2] = { -1, -1 };
109
108
        
110
 
        LOGPRINTF(LOG_INFO, "initializing USB receiver");
 
109
        LOGPRINTF(1, "initializing USB receiver");
111
110
        
112
111
        init_rec_buffer();
113
112
        
116
115
         * end of this pipe. */
117
116
        if (pipe(pipe_fd) != 0)
118
117
        {
119
 
                logprintf(LOG_ERR, "couldn't open pipe: %s", strerror(errno));
 
118
                logperror(LOG_ERR, "couldn't open pipe");
120
119
                return 0;
121
120
        }
122
121
        hw.fd = pipe_fd[0];
137
136
        dev_handle = usb_open(usb_dev);
138
137
        if (dev_handle == NULL)
139
138
        {
140
 
                logprintf(LOG_ERR, "couldn't open USB receiver: %s",
141
 
                                strerror(errno));
 
139
                logperror(LOG_ERR, "couldn't open USB receiver");
142
140
                goto fail;
143
141
        }
144
142
        
145
143
        if (usb_claim_interface(dev_handle, 0) != 0)
146
144
        {
147
 
                logprintf(LOG_ERR, "couldn't claim USB interface: %s",
148
 
                                strerror(errno));
 
145
                logperror(LOG_ERR, "couldn't claim USB interface");
149
146
                goto fail;
150
147
        }
151
148
        
163
160
        child = fork();
164
161
        if (child == -1)
165
162
        {
166
 
                logprintf(LOG_ERR, "couldn't fork child process: %s",
167
 
                                strerror(errno));
 
163
                logperror(LOG_ERR, "couldn't fork child process");
168
164
                goto fail;
169
165
        }
170
166
        else if (child == 0)
172
168
                usb_read_loop(pipe_fd[1]);
173
169
        }
174
170
        
175
 
        LOGPRINTF(LOG_INFO, "USB receiver initialized");
 
171
        LOGPRINTF(1, "USB receiver initialized");
176
172
        return 1;
177
173
 
178
174
fail:
214
210
 
215
211
static char *ati_rec(struct ir_remote *remotes)
216
212
{
217
 
        if (!clear_rec_buffer()) return NULL;
 
213
        if (!clear_rec_buffer())
 
214
        {
 
215
                ati_deinit();
 
216
                return NULL;
 
217
        }
218
218
        return decode_all(remotes);
219
219
}
220
220
 
312
312
                                &buf[0], sizeof(buf), USB_TIMEOUT);
313
313
                if (bytes_r < 0)
314
314
                {
315
 
                        if (errno == EAGAIN) continue;
316
 
                        logprintf(LOG_ERR, "can't read from USB device: %s",
317
 
                                        strerror(errno));
 
315
                        if (errno == EAGAIN || errno == ETIMEDOUT) continue;
 
316
                        
 
317
                        logperror(LOG_ERR, "can't read from USB device");
318
318
                        err = 1; goto done;
319
319
                }
320
320
                
340
340
                        bytes_w = write(fd, buf + pos, bytes_r - pos);
341
341
                        if (bytes_w < 0)
342
342
                        {
343
 
                                logprintf(LOG_ERR, "can't write to pipe: %s",
344
 
                                                strerror(errno));
 
343
                                logperror(LOG_ERR, "can't write to pipe");
345
344
                                err = 1; goto done;
346
345
                        }
347
346
                }
348
347
        }
349
348
        
350
349
done:
 
350
        close(fd);
351
351
        if (!usb_close(dev_handle)) err = 1;
352
352
        _exit(err);
353
353
}