blob: 7c46477af2a275b7da701087dfd8424506c37d5d [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 Thompson7d9485e2010-02-15 06:46:08 -080041 int fb_count;
Bernie Thompson33077b82010-09-05 16:35:19 -070042 bool virtualized; /* true when physical usb device not present */
43 struct delayed_work free_framebuffer_work;
Bernie Thompson7d9485e2010-02-15 06:46:08 -080044 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 */
Roberto De Ioris88e58b12009-06-03 14:03:06 -070057};
58
Bernie Thompsoncc403dc2010-02-15 06:45:49 -080059#define NR_USB_REQUEST_I2C_SUB_IO 0x02
60#define NR_USB_REQUEST_CHANNEL 0x12
61
Bernie Thompson4a4854d2010-02-15 06:45:55 -080062/* -BULK_SIZE as per usb-skeleton. Can we get full page and avoid overhead? */
63#define BULK_SIZE 512
64#define MAX_TRANSFER (PAGE_SIZE*16 - BULK_SIZE)
65#define WRITES_IN_FLIGHT (4)
66
67#define GET_URB_TIMEOUT HZ
68#define FREE_URB_TIMEOUT (HZ*2)
69
Bernie Thompson530f43a2010-02-15 06:46:21 -080070#define BPP 2
71#define MAX_CMD_PIXELS 255
Roberto De Ioris88e58b12009-06-03 14:03:06 -070072
Bernie Thompson530f43a2010-02-15 06:46:21 -080073#define RLX_HEADER_BYTES 7
74#define MIN_RLX_PIX_BYTES 4
75#define MIN_RLX_CMD_BYTES (RLX_HEADER_BYTES + MIN_RLX_PIX_BYTES)
Roberto De Ioris7316bc52009-06-10 23:02:19 -070076
Bernie Thompson530f43a2010-02-15 06:46:21 -080077#define RLE_HEADER_BYTES 6
78#define MIN_RLE_PIX_BYTES 3
79#define MIN_RLE_CMD_BYTES (RLE_HEADER_BYTES + MIN_RLE_PIX_BYTES)
Roberto De Ioris7316bc52009-06-10 23:02:19 -070080
Bernie Thompson530f43a2010-02-15 06:46:21 -080081#define RAW_HEADER_BYTES 6
82#define MIN_RAW_PIX_BYTES 2
83#define MIN_RAW_CMD_BYTES (RAW_HEADER_BYTES + MIN_RAW_PIX_BYTES)
Roberto De Ioris7316bc52009-06-10 23:02:19 -070084
Bernie Thompson530f43a2010-02-15 06:46:21 -080085/* remove these once align.h patch is taken into kernel */
86#define DL_ALIGN_UP(x, a) ALIGN(x, a)
87#define DL_ALIGN_DOWN(x, a) ALIGN(x-(a-1), a)
Greg Kroah-Hartman39e7df52009-06-03 14:47:00 -070088
Bernie Thompson7d9485e2010-02-15 06:46:08 -080089/* remove once this gets added to sysfs.h */
90#define __ATTR_RW(attr) __ATTR(attr, 0644, attr##_show, attr##_store)
91
Bernie Thompson33077b82010-09-05 16:35:19 -070092/*
93 * udlfb is both a usb device, and a framebuffer device.
94 * They may exist at the same time, but during various stages
95 * inactivity, teardown, or "virtual" operation, only one or the
96 * other will exist (one will outlive the other). So we can't
97 * call the dev_*() macros, because we don't have a stable dev object.
98 */
Bernie Thompson4a4854d2010-02-15 06:45:55 -080099#define dl_err(format, arg...) \
Bernie Thompson33077b82010-09-05 16:35:19 -0700100 pr_err("udlfb: " format, ## arg)
Bernie Thompson4a4854d2010-02-15 06:45:55 -0800101#define dl_warn(format, arg...) \
Bernie Thompson33077b82010-09-05 16:35:19 -0700102 pr_warning("udlfb: " format, ## arg)
Bernie Thompson4a4854d2010-02-15 06:45:55 -0800103#define dl_notice(format, arg...) \
Bernie Thompson33077b82010-09-05 16:35:19 -0700104 pr_notice("udlfb: " format, ## arg)
Bernie Thompson4a4854d2010-02-15 06:45:55 -0800105#define dl_info(format, arg...) \
Bernie Thompson33077b82010-09-05 16:35:19 -0700106 pr_info("udlfb: " format, ## arg)
107
Greg Kroah-Hartman39e7df52009-06-03 14:47:00 -0700108#endif