/alps/ipecamera

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/ipecamera

« back to all changes in this revision

Viewing changes to irq.c

  • Committer: Suren A. Chilingaryan
  • Date: 2015-04-27 00:28:57 UTC
  • Revision ID: csa@suren.me-20150427002857-82fk6r3e8rfgy4wr
First stand-alone ipecamera implementation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdio.h>
2
 
#include <string.h>
3
 
#include <strings.h>
4
 
#include <stdlib.h>
5
 
#include <stdint.h>
6
 
#include <stdarg.h>
7
 
#include <fcntl.h>
8
 
#include <unistd.h>
9
 
#include <sys/ioctl.h>
10
 
#include <sys/mman.h>
11
 
#include <arpa/inet.h>
12
 
#include <errno.h>
13
 
#include <assert.h>
14
 
 
15
 
#include "pci.h"
16
 
 
17
 
#include "tools.h"
18
 
#include "error.h"
19
 
 
20
 
int pcilib_wait_irq(pcilib_t *ctx, pcilib_irq_hw_source_t source, pcilib_timeout_t timeout, size_t *count) {
21
 
    int err;
22
 
    
23
 
    interrupt_wait_t arg = { 0 };
24
 
    
25
 
    arg.source = source;
26
 
    arg.timeout = timeout;
27
 
 
28
 
    if (count) arg.count = 1;
29
 
 
30
 
    err = ioctl(ctx->handle, PCIDRIVER_IOC_WAITI, &arg);
31
 
    if (err) {
32
 
        pcilib_error("PCIDRIVER_IOC_WAITI ioctl have failed");
33
 
        return PCILIB_ERROR_FAILED;
34
 
    }
35
 
    
36
 
    if (!arg.count) return PCILIB_ERROR_TIMEOUT;
37
 
 
38
 
    if (count) *count = arg.count;
39
 
    
40
 
    return 0;
41
 
}
42
 
 
43
 
int pcilib_clear_irq(pcilib_t *ctx, pcilib_irq_hw_source_t source) {
44
 
    int err;
45
 
    
46
 
    err = ioctl(ctx->handle, PCIDRIVER_IOC_CLEAR_IOQ, source);
47
 
    if (err) {
48
 
        pcilib_error("PCIDRIVER_IOC_CLEAR_IOQ ioctl have failed");
49
 
        return PCILIB_ERROR_FAILED;
50
 
    }
51
 
    
52
 
    return 0;
53
 
}
54
 
 
55