Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

#ifndef _GPIO_HEADER_INCLUDED_
#define _GPIO_HEADER_INCLUDED_

#include <linux/list.h>
#include "drivers/compbttv.h"
#include <sys/types.h>

/* base "class" for dispatch requests */
struct gpio_request {
    struct list_head list;          /* linked list of requests */
};

/* request queues */
typedef struct _request_queue_s {
    struct list_head list;          /* list of pending requests */
} request_queue_t;

#define init_request_queue(rq)                                  \
do {                                                            \
    INIT_LIST_HEAD(&((rq)->list));                              \
} while(0)


struct gpio_adapter {
    /* overlapped data members: see "struct bttv" */
    struct pci_dev *dev;
    unsigned char *bt848_mem; /* pointer to mapped IO memory */
   
    /* gpio async management variables */
    unsigned long state;    //GPIO_HW_LOCKED   == someone has exclusive hw access
                            //GPIO_ASYNC_MOD   == change is pending
                            //GPIO_TASK_ACTIVE == request service task running
   
    __u32 sync_bits;      // current sync state (when hardware not locked)
    __u32 async_mask;     // mask of bits allocated to async control
    __u32 async_bits;     // current (or pending) state.  see: async_change

    /* gpio sync management variables */
    request_queue_t request_queue;
    request_queue_t free_queue;
   
    void *private_data;
};

extern void init_gpio_adapter ( struct gpio_adapter * );

/* gpio state bits */
#define GPIO_HW_LOCKED      0
#define GPIO_ASYNC_MOD      1
#define GPIO_TASK_ACTIVE    2
#define GPIO_USER_STATE     3       /* the base for user defined status */

/* gpio async methods */
extern void gpio_set   ( struct gpio_adapter *, __u32 data );
extern void gpio_and   ( struct gpio_adapter *, __u32 and_data );
extern void gpio_or    ( struct gpio_adapter *, __u32 or_data );
extern void gpio_andor ( struct gpio_adapter *, __u32 and_data, __u32 or_data );

/* request queueing methods */
extern void gpio_commit_request( struct gpio_adapter *, struct gpio_request * );
extern void gpio_commit_transaction( struct gpio_adapter *, struct list_head * );

#endif /* _GPIO_HEADER_INCLUDED_ */