Commit | Line | Data |
---|---|---|
39e7df5d GKH |
1 | #ifndef UDLFB_H |
2 | #define UDLFB_H | |
88e58b1a | 3 | |
39e7df5d GKH |
4 | /* as libdlo */ |
5 | #define BUF_HIGH_WATER_MARK 1024 | |
6 | #define BUF_SIZE (64*1024) | |
88e58b1a | 7 | |
4a4854dd BT |
8 | struct urb_node { |
9 | struct list_head entry; | |
10 | struct dlfb_data *dev; | |
11 | struct urb *urb; | |
12 | }; | |
13 | ||
14 | struct urb_list { | |
15 | struct list_head list; | |
16 | spinlock_t lock; | |
17 | struct semaphore limit_sem; | |
18 | int available; | |
19 | int count; | |
20 | size_t size; | |
21 | }; | |
22 | ||
88e58b1a RDI |
23 | struct dlfb_data { |
24 | struct usb_device *udev; | |
4a4854dd | 25 | struct device *gdev; /* &udev->dev */ |
88e58b1a RDI |
26 | struct usb_interface *interface; |
27 | struct urb *tx_urb, *ctrl_urb; | |
28 | struct usb_ctrlrequest dr; | |
29 | struct fb_info *info; | |
4a4854dd BT |
30 | struct urb_list urbs; |
31 | struct kref kref; | |
88e58b1a RDI |
32 | char *buf; |
33 | char *bufend; | |
34 | char *backing_buffer; | |
35 | struct mutex bulk_mutex; | |
4a4854dd | 36 | atomic_t lost_pixels; /* 1 = a render op failed. Need screen refresh */ |
88e58b1a RDI |
37 | char edid[128]; |
38 | int screen_size; | |
39 | int line_length; | |
40 | struct completion done; | |
41 | int base16; | |
7316bc55 | 42 | int base16d; |
88e58b1a | 43 | int base8; |
7316bc55 | 44 | int base8d; |
59277b67 | 45 | u32 pseudo_palette[256]; |
88e58b1a RDI |
46 | }; |
47 | ||
cc403dc6 BT |
48 | #define NR_USB_REQUEST_I2C_SUB_IO 0x02 |
49 | #define NR_USB_REQUEST_CHANNEL 0x12 | |
50 | ||
4a4854dd BT |
51 | /* -BULK_SIZE as per usb-skeleton. Can we get full page and avoid overhead? */ |
52 | #define BULK_SIZE 512 | |
53 | #define MAX_TRANSFER (PAGE_SIZE*16 - BULK_SIZE) | |
54 | #define WRITES_IN_FLIGHT (4) | |
55 | ||
56 | #define GET_URB_TIMEOUT HZ | |
57 | #define FREE_URB_TIMEOUT (HZ*2) | |
58 | ||
88e58b1a RDI |
59 | static void dlfb_bulk_callback(struct urb *urb) |
60 | { | |
88e58b1a RDI |
61 | struct dlfb_data *dev_info = urb->context; |
62 | complete(&dev_info->done); | |
88e58b1a RDI |
63 | } |
64 | ||
7316bc55 RDI |
65 | static void dlfb_edid(struct dlfb_data *dev_info) |
66 | { | |
67 | int i; | |
68 | int ret; | |
69 | char rbuf[2]; | |
70 | ||
71 | for (i = 0; i < 128; i++) { | |
72 | ret = | |
73 | usb_control_msg(dev_info->udev, | |
74 | usb_rcvctrlpipe(dev_info->udev, 0), (0x02), | |
75 | (0x80 | (0x02 << 5)), i << 8, 0xA1, rbuf, 2, | |
76 | 0); | |
7316bc55 RDI |
77 | dev_info->edid[i] = rbuf[1]; |
78 | } | |
79 | ||
80 | } | |
81 | ||
88e58b1a RDI |
82 | static int dlfb_bulk_msg(struct dlfb_data *dev_info, int len) |
83 | { | |
88e58b1a RDI |
84 | int ret; |
85 | ||
86 | init_completion(&dev_info->done); | |
87 | ||
88 | dev_info->tx_urb->actual_length = 0; | |
89 | dev_info->tx_urb->transfer_buffer_length = len; | |
90 | ||
91 | ret = usb_submit_urb(dev_info->tx_urb, GFP_KERNEL); | |
92 | if (!wait_for_completion_timeout(&dev_info->done, 1000)) { | |
93 | usb_kill_urb(dev_info->tx_urb); | |
94 | printk("usb timeout !!!\n"); | |
95 | } | |
96 | ||
97 | return dev_info->tx_urb->actual_length; | |
88e58b1a RDI |
98 | } |
99 | ||
59277b67 | 100 | #define dlfb_set_register insert_command |
39e7df5d | 101 | |
4a4854dd BT |
102 | #define dl_err(format, arg...) \ |
103 | dev_err(dev->gdev, "dlfb: " format, ## arg) | |
104 | #define dl_warn(format, arg...) \ | |
105 | dev_warn(dev->gdev, "dlfb: " format, ## arg) | |
106 | #define dl_notice(format, arg...) \ | |
107 | dev_notice(dev->gdev, "dlfb: " format, ## arg) | |
108 | #define dl_info(format, arg...) \ | |
109 | dev_info(dev->gdev, "dlfb: " format, ## arg) | |
39e7df5d | 110 | #endif |