xref: /linux/include/video/udlfb.h (revision 4be5e8648b0c287aefc6ac3f3a0b12c696054f43)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef UDLFB_H
3 #define UDLFB_H
4 
5 /*
6  * TODO: Propose standard fb.h ioctl for reporting damage,
7  * using _IOWR() and one of the existing area structs from fb.h
8  * Consider these ioctls deprecated, but they're still used by the
9  * DisplayLink X server as yet - need both to be modified in tandem
10  * when new ioctl(s) are ready.
11  */
12 #define DLFB_IOCTL_RETURN_EDID	 0xAD
13 #define DLFB_IOCTL_REPORT_DAMAGE 0xAA
14 struct dloarea {
15 	int x, y;
16 	int w, h;
17 	int x2, y2;
18 };
19 
20 struct urb_node {
21 	struct list_head entry;
22 	struct dlfb_data *dlfb;
23 	struct urb *urb;
24 };
25 
26 struct urb_list {
27 	struct list_head list;
28 	spinlock_t lock;
29 	struct semaphore limit_sem;
30 	int available;
31 	int count;
32 	size_t size;
33 };
34 
35 struct dlfb_data {
36 	struct usb_device *udev;
37 	struct fb_info *info;
38 	struct urb_list urbs;
39 	char *backing_buffer;
40 	int fb_count;
41 	bool virtualized; /* true when physical usb device not present */
42 	atomic_t usb_active; /* 0 = update virtual buffer, but no usb traffic */
43 	atomic_t lost_pixels; /* 1 = a render op failed. Need screen refresh */
44 	char *edid; /* null until we read edid from hw or get from sysfs */
45 	size_t edid_size;
46 	int sku_pixel_limit;
47 	int base16;
48 	int base8;
49 	u32 pseudo_palette[256];
50 	int blank_mode; /*one of FB_BLANK_ */
51 	struct mutex render_mutex;
52 	int damage_x;
53 	int damage_y;
54 	int damage_x2;
55 	int damage_y2;
56 	spinlock_t damage_lock;
57 	struct work_struct damage_work;
58 	struct fb_ops ops;
59 	/* blit-only rendering path metrics, exposed through sysfs */
60 	atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
61 	atomic_t bytes_identical; /* saved effort with backbuffer comparison */
62 	atomic_t bytes_sent; /* to usb, after compression including overhead */
63 	atomic_t cpu_kcycles_used; /* transpired during pixel processing */
64 	struct fb_var_screeninfo current_mode;
65 	struct list_head deferred_free;
66 };
67 
68 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
69 #define NR_USB_REQUEST_CHANNEL 0x12
70 
71 /* -BULK_SIZE as per usb-skeleton. Can we get full page and avoid overhead? */
72 #define BULK_SIZE 512
73 #define MAX_TRANSFER (PAGE_SIZE*16 - BULK_SIZE)
74 #define WRITES_IN_FLIGHT (4)
75 
76 #define MAX_VENDOR_DESCRIPTOR_SIZE 256
77 
78 #define GET_URB_TIMEOUT	HZ
79 #define FREE_URB_TIMEOUT (HZ*2)
80 
81 #define BPP                     2
82 #define MAX_CMD_PIXELS		255
83 
84 #define RLX_HEADER_BYTES	7
85 #define MIN_RLX_PIX_BYTES       4
86 #define MIN_RLX_CMD_BYTES	(RLX_HEADER_BYTES + MIN_RLX_PIX_BYTES)
87 
88 #define RLE_HEADER_BYTES	6
89 #define MIN_RLE_PIX_BYTES	3
90 #define MIN_RLE_CMD_BYTES	(RLE_HEADER_BYTES + MIN_RLE_PIX_BYTES)
91 
92 #define RAW_HEADER_BYTES	6
93 #define MIN_RAW_PIX_BYTES	2
94 #define MIN_RAW_CMD_BYTES	(RAW_HEADER_BYTES + MIN_RAW_PIX_BYTES)
95 
96 #define DL_DEFIO_WRITE_DELAY    msecs_to_jiffies(HZ <= 300 ? 4 : 10) /* optimal value for 720p video */
97 #define DL_DEFIO_WRITE_DISABLE  (HZ*60) /* "disable" with long delay */
98 
99 /* remove these once align.h patch is taken into kernel */
100 #define DL_ALIGN_UP(x, a) ALIGN(x, a)
101 #define DL_ALIGN_DOWN(x, a) ALIGN_DOWN(x, a)
102 
103 #endif
104