blob: b07a69371f1f2109d3b65d480a51c97181787c96 [file] [log] [blame]
Greg Kroah-Hartman39e7df52009-06-03 14:47:00 -07001#ifndef UDLFB_H
2#define UDLFB_H
Roberto De Ioris88e58b12009-06-03 14:03:06 -07003
Bernie Thompson530f43a2010-02-15 06:46:21 -08004/*
5 * TODO: Propose standard fb.h ioctl for reporting damage,
6 * using _IOWR() and one of the existing area structs from fb.h
7 * Consider these ioctls deprecated, but they're still used by the
8 * DisplayLink X server as yet - need both to be modified in tandem
9 * when new ioctl(s) are ready.
10 */
11#define DLFB_IOCTL_RETURN_EDID 0xAD
12#define DLFB_IOCTL_REPORT_DAMAGE 0xAA
13struct dloarea {
14 int x, y;
15 int w, h;
16 int x2, y2;
17};
Roberto De Ioris88e58b12009-06-03 14:03:06 -070018
Bernie Thompson4a4854d2010-02-15 06:45:55 -080019struct urb_node {
20 struct list_head entry;
21 struct dlfb_data *dev;
22 struct urb *urb;
23};
24
25struct urb_list {
26 struct list_head list;
27 spinlock_t lock;
28 struct semaphore limit_sem;
29 int available;
30 int count;
31 size_t size;
32};
33
Roberto De Ioris88e58b12009-06-03 14:03:06 -070034struct dlfb_data {
35 struct usb_device *udev;
Bernie Thompson4a4854d2010-02-15 06:45:55 -080036 struct device *gdev; /* &udev->dev */
Roberto De Ioris88e58b12009-06-03 14:03:06 -070037 struct fb_info *info;
Bernie Thompson4a4854d2010-02-15 06:45:55 -080038 struct urb_list urbs;
39 struct kref kref;
Roberto De Ioris88e58b12009-06-03 14:03:06 -070040 char *backing_buffer;
Bernie Thompson2469d5d2010-02-15 06:46:13 -080041 struct delayed_work deferred_work;
42 struct mutex fb_open_lock;
Bernie Thompson7d9485e2010-02-15 06:46:08 -080043 int fb_count;
44 atomic_t usb_active; /* 0 = update virtual buffer, but no usb traffic */
Bernie Thompson4a4854d2010-02-15 06:45:55 -080045 atomic_t lost_pixels; /* 1 = a render op failed. Need screen refresh */
Bernie Thompson7d9485e2010-02-15 06:46:08 -080046 atomic_t use_defio; /* 0 = rely on ioctls and blit/copy/fill rects */
Roberto De Ioris88e58b12009-06-03 14:03:06 -070047 char edid[128];
Bernie Thompson7d9485e2010-02-15 06:46:08 -080048 int sku_pixel_limit;
Roberto De Ioris88e58b12009-06-03 14:03:06 -070049 int base16;
50 int base8;
Bernie Thompson59277b62009-11-24 15:52:21 -080051 u32 pseudo_palette[256];
Bernie Thompson7d9485e2010-02-15 06:46:08 -080052 /* blit-only rendering path metrics, exposed through sysfs */
53 atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
54 atomic_t bytes_identical; /* saved effort with backbuffer comparison */
55 atomic_t bytes_sent; /* to usb, after compression including overhead */
56 atomic_t cpu_kcycles_used; /* transpired during pixel processing */
57 /* interface usage metrics. Clients can call driver via several */
58 atomic_t blit_count;
59 atomic_t copy_count;
60 atomic_t fill_count;
61 atomic_t damage_count;
62 atomic_t defio_fault_count;
Roberto De Ioris88e58b12009-06-03 14:03:06 -070063};
64
Bernie Thompsoncc403dc2010-02-15 06:45:49 -080065#define NR_USB_REQUEST_I2C_SUB_IO 0x02
66#define NR_USB_REQUEST_CHANNEL 0x12
67
Bernie Thompson4a4854d2010-02-15 06:45:55 -080068/* -BULK_SIZE as per usb-skeleton. Can we get full page and avoid overhead? */
69#define BULK_SIZE 512
70#define MAX_TRANSFER (PAGE_SIZE*16 - BULK_SIZE)
71#define WRITES_IN_FLIGHT (4)
72
73#define GET_URB_TIMEOUT HZ
74#define FREE_URB_TIMEOUT (HZ*2)
75
Bernie Thompson530f43a2010-02-15 06:46:21 -080076#define BPP 2
77#define MAX_CMD_PIXELS 255
Roberto De Ioris88e58b12009-06-03 14:03:06 -070078
Bernie Thompson530f43a2010-02-15 06:46:21 -080079#define RLX_HEADER_BYTES 7
80#define MIN_RLX_PIX_BYTES 4
81#define MIN_RLX_CMD_BYTES (RLX_HEADER_BYTES + MIN_RLX_PIX_BYTES)
Roberto De Ioris7316bc52009-06-10 23:02:19 -070082
Bernie Thompson530f43a2010-02-15 06:46:21 -080083#define RLE_HEADER_BYTES 6
84#define MIN_RLE_PIX_BYTES 3
85#define MIN_RLE_CMD_BYTES (RLE_HEADER_BYTES + MIN_RLE_PIX_BYTES)
Roberto De Ioris7316bc52009-06-10 23:02:19 -070086
Bernie Thompson530f43a2010-02-15 06:46:21 -080087#define RAW_HEADER_BYTES 6
88#define MIN_RAW_PIX_BYTES 2
89#define MIN_RAW_CMD_BYTES (RAW_HEADER_BYTES + MIN_RAW_PIX_BYTES)
Roberto De Ioris7316bc52009-06-10 23:02:19 -070090
Bernie Thompson530f43a2010-02-15 06:46:21 -080091/* remove these once align.h patch is taken into kernel */
92#define DL_ALIGN_UP(x, a) ALIGN(x, a)
93#define DL_ALIGN_DOWN(x, a) ALIGN(x-(a-1), a)
Greg Kroah-Hartman39e7df52009-06-03 14:47:00 -070094
Bernie Thompson7d9485e2010-02-15 06:46:08 -080095/* remove once this gets added to sysfs.h */
96#define __ATTR_RW(attr) __ATTR(attr, 0644, attr##_show, attr##_store)
97
Bernie Thompson4a4854d2010-02-15 06:45:55 -080098#define dl_err(format, arg...) \
99 dev_err(dev->gdev, "dlfb: " format, ## arg)
100#define dl_warn(format, arg...) \
101 dev_warn(dev->gdev, "dlfb: " format, ## arg)
102#define dl_notice(format, arg...) \
103 dev_notice(dev->gdev, "dlfb: " format, ## arg)
104#define dl_info(format, arg...) \
105 dev_info(dev->gdev, "dlfb: " format, ## arg)
Greg Kroah-Hartman39e7df52009-06-03 14:47:00 -0700106#endif