/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 driver/common.h

  • 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
 
#ifndef _PCIDRIVER_COMMON_H
2
 
#define _PCIDRIVER_COMMON_H
3
 
 
4
 
#include "pcilib_types.h"
5
 
 
6
 
/*************************************************************************/
7
 
/* Private data types and structures */
8
 
 
9
 
 
10
 
/* Define an entry in the kmem list (this list is per device) */
11
 
/* This list keeps references to the allocated kernel buffers */
12
 
typedef struct {
13
 
        int id;
14
 
        enum dma_data_direction direction;
15
 
        
16
 
        struct list_head list;
17
 
        dma_addr_t dma_handle;
18
 
        unsigned long cpua;
19
 
        unsigned long size;
20
 
        unsigned long type;
21
 
        unsigned long align;
22
 
 
23
 
        unsigned long use;
24
 
        unsigned long item;
25
 
 
26
 
        spinlock_t lock;
27
 
        unsigned long mode;
28
 
        unsigned long refs;
29
 
 
30
 
        struct class_device_attribute sysfs_attr;       /* initialized when adding the entry */
31
 
} pcidriver_kmem_entry_t;
32
 
 
33
 
/* Define an entry in the umem list (this list is per device) */
34
 
/* This list keeps references to the SG lists for each mapped userspace region */
35
 
typedef struct {
36
 
        int id;
37
 
        struct list_head list;
38
 
        unsigned int nr_pages;          /* number of pages for this user memeory area */
39
 
        struct page **pages;            /* list of pointers to the pages */
40
 
        unsigned int nents;                     /* actual entries in the scatter/gatter list (NOT nents for the map function, but the result) */
41
 
        struct scatterlist *sg;         /* list of sg entries */
42
 
        struct class_device_attribute sysfs_attr;       /* initialized when adding the entry */
43
 
} pcidriver_umem_entry_t;
44
 
 
45
 
/* Hold the driver private data */
46
 
typedef struct  {
47
 
        dev_t devno;                                            /* device number (major and minor) */
48
 
        struct pci_dev *pdev;                           /* PCI device */
49
 
        struct class_device *class_dev;         /* Class device */
50
 
        struct cdev cdev;                                       /* char device struct */
51
 
        int mmap_mode;                                          /* current mmap mode */
52
 
        int mmap_area;                                          /* current PCI mmap area */
53
 
 
54
 
#ifdef ENABLE_IRQ
55
 
        int irq_enabled;                                        /* Non-zero if IRQ is enabled */
56
 
        int irq_count;                                          /* Just an IRQ counter */
57
 
 
58
 
        wait_queue_head_t irq_queues[ PCIDRIVER_INT_MAXSOURCES ];
59
 
                                                                                /* One queue per interrupt source */
60
 
        atomic_t irq_outstanding[ PCIDRIVER_INT_MAXSOURCES ];
61
 
                                                                                /* Outstanding interrupts per queue */
62
 
        volatile unsigned int *bars_kmapped[6];         /* PCI BARs mmapped in kernel space */
63
 
 
64
 
#endif
65
 
        
66
 
        spinlock_t kmemlist_lock;                       /* Spinlock to lock kmem list operations */
67
 
        struct list_head kmem_list;                     /* List of 'kmem_list_entry's associated with this device */
68
 
        atomic_t kmem_count;                            /* id for next kmem entry */
69
 
 
70
 
        int kmem_cur_id;                                /* Currently selected kmem buffer, for mmap */
71
 
        
72
 
        spinlock_t umemlist_lock;                       /* Spinlock to lock umem list operations */
73
 
        struct list_head umem_list;                     /* List of 'umem_list_entry's associated with this device */
74
 
        atomic_t umem_count;                            /* id for next umem entry */
75
 
 
76
 
        int msi_mode;                                   /* Flag specifying if interrupt have been initialized in MSI mode */
77
 
        atomic_t refs;                                  /* Reference counter */
78
 
} pcidriver_privdata_t;
79
 
 
80
 
 
81
 
void pcidriver_module_get(pcidriver_privdata_t *privdata);
82
 
void pcidriver_module_put(pcidriver_privdata_t *privdata);
83
 
 
84
 
/*************************************************************************/
85
 
/* Some nice defines that make code more readable */
86
 
/* This is to print nice info in the log */
87
 
 
88
 
#ifdef DEBUG
89
 
 #define mod_info( args... ) \
90
 
    do { printk( KERN_INFO "%s - %s : ", MODNAME , __FUNCTION__ );\
91
 
    printk( args ); } while(0)
92
 
 #define mod_info_dbg( args... ) \
93
 
    do { printk( KERN_INFO "%s - %s : ", MODNAME , __FUNCTION__ );\
94
 
    printk( args ); } while(0)
95
 
#else
96
 
 #define mod_info( args... ) \
97
 
    do { printk( KERN_INFO "%s: ", MODNAME );\
98
 
    printk( args ); } while(0)
99
 
 #define mod_info_dbg( args... ) 
100
 
#endif
101
 
 
102
 
#define mod_crit( args... ) \
103
 
    do { printk( KERN_CRIT "%s: ", MODNAME );\
104
 
    printk( args ); } while(0)
105
 
 
106
 
#define MIN(a, b) ((a) < (b) ? (a) : (b))
107
 
 
108
 
#endif