18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef UDLFB_H 38c2ecf20Sopenharmony_ci#define UDLFB_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * TODO: Propose standard fb.h ioctl for reporting damage, 78c2ecf20Sopenharmony_ci * using _IOWR() and one of the existing area structs from fb.h 88c2ecf20Sopenharmony_ci * Consider these ioctls deprecated, but they're still used by the 98c2ecf20Sopenharmony_ci * DisplayLink X server as yet - need both to be modified in tandem 108c2ecf20Sopenharmony_ci * when new ioctl(s) are ready. 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci#define DLFB_IOCTL_RETURN_EDID 0xAD 138c2ecf20Sopenharmony_ci#define DLFB_IOCTL_REPORT_DAMAGE 0xAA 148c2ecf20Sopenharmony_cistruct dloarea { 158c2ecf20Sopenharmony_ci int x, y; 168c2ecf20Sopenharmony_ci int w, h; 178c2ecf20Sopenharmony_ci int x2, y2; 188c2ecf20Sopenharmony_ci}; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cistruct urb_node { 218c2ecf20Sopenharmony_ci struct list_head entry; 228c2ecf20Sopenharmony_ci struct dlfb_data *dlfb; 238c2ecf20Sopenharmony_ci struct urb *urb; 248c2ecf20Sopenharmony_ci}; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistruct urb_list { 278c2ecf20Sopenharmony_ci struct list_head list; 288c2ecf20Sopenharmony_ci spinlock_t lock; 298c2ecf20Sopenharmony_ci struct semaphore limit_sem; 308c2ecf20Sopenharmony_ci int available; 318c2ecf20Sopenharmony_ci int count; 328c2ecf20Sopenharmony_ci size_t size; 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct dlfb_data { 368c2ecf20Sopenharmony_ci struct usb_device *udev; 378c2ecf20Sopenharmony_ci struct fb_info *info; 388c2ecf20Sopenharmony_ci struct urb_list urbs; 398c2ecf20Sopenharmony_ci char *backing_buffer; 408c2ecf20Sopenharmony_ci int fb_count; 418c2ecf20Sopenharmony_ci bool virtualized; /* true when physical usb device not present */ 428c2ecf20Sopenharmony_ci atomic_t usb_active; /* 0 = update virtual buffer, but no usb traffic */ 438c2ecf20Sopenharmony_ci atomic_t lost_pixels; /* 1 = a render op failed. Need screen refresh */ 448c2ecf20Sopenharmony_ci char *edid; /* null until we read edid from hw or get from sysfs */ 458c2ecf20Sopenharmony_ci size_t edid_size; 468c2ecf20Sopenharmony_ci int sku_pixel_limit; 478c2ecf20Sopenharmony_ci int base16; 488c2ecf20Sopenharmony_ci int base8; 498c2ecf20Sopenharmony_ci u32 pseudo_palette[256]; 508c2ecf20Sopenharmony_ci int blank_mode; /*one of FB_BLANK_ */ 518c2ecf20Sopenharmony_ci struct mutex render_mutex; 528c2ecf20Sopenharmony_ci int damage_x; 538c2ecf20Sopenharmony_ci int damage_y; 548c2ecf20Sopenharmony_ci int damage_x2; 558c2ecf20Sopenharmony_ci int damage_y2; 568c2ecf20Sopenharmony_ci spinlock_t damage_lock; 578c2ecf20Sopenharmony_ci struct work_struct damage_work; 588c2ecf20Sopenharmony_ci struct fb_ops ops; 598c2ecf20Sopenharmony_ci /* blit-only rendering path metrics, exposed through sysfs */ 608c2ecf20Sopenharmony_ci atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */ 618c2ecf20Sopenharmony_ci atomic_t bytes_identical; /* saved effort with backbuffer comparison */ 628c2ecf20Sopenharmony_ci atomic_t bytes_sent; /* to usb, after compression including overhead */ 638c2ecf20Sopenharmony_ci atomic_t cpu_kcycles_used; /* transpired during pixel processing */ 648c2ecf20Sopenharmony_ci struct fb_var_screeninfo current_mode; 658c2ecf20Sopenharmony_ci struct list_head deferred_free; 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define NR_USB_REQUEST_I2C_SUB_IO 0x02 698c2ecf20Sopenharmony_ci#define NR_USB_REQUEST_CHANNEL 0x12 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* -BULK_SIZE as per usb-skeleton. Can we get full page and avoid overhead? */ 728c2ecf20Sopenharmony_ci#define BULK_SIZE 512 738c2ecf20Sopenharmony_ci#define MAX_TRANSFER (PAGE_SIZE*16 - BULK_SIZE) 748c2ecf20Sopenharmony_ci#define WRITES_IN_FLIGHT (4) 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#define MAX_VENDOR_DESCRIPTOR_SIZE 256 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define GET_URB_TIMEOUT HZ 798c2ecf20Sopenharmony_ci#define FREE_URB_TIMEOUT (HZ*2) 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define BPP 2 828c2ecf20Sopenharmony_ci#define MAX_CMD_PIXELS 255 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define RLX_HEADER_BYTES 7 858c2ecf20Sopenharmony_ci#define MIN_RLX_PIX_BYTES 4 868c2ecf20Sopenharmony_ci#define MIN_RLX_CMD_BYTES (RLX_HEADER_BYTES + MIN_RLX_PIX_BYTES) 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define RLE_HEADER_BYTES 6 898c2ecf20Sopenharmony_ci#define MIN_RLE_PIX_BYTES 3 908c2ecf20Sopenharmony_ci#define MIN_RLE_CMD_BYTES (RLE_HEADER_BYTES + MIN_RLE_PIX_BYTES) 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define RAW_HEADER_BYTES 6 938c2ecf20Sopenharmony_ci#define MIN_RAW_PIX_BYTES 2 948c2ecf20Sopenharmony_ci#define MIN_RAW_CMD_BYTES (RAW_HEADER_BYTES + MIN_RAW_PIX_BYTES) 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#define DL_DEFIO_WRITE_DELAY msecs_to_jiffies(HZ <= 300 ? 4 : 10) /* optimal value for 720p video */ 978c2ecf20Sopenharmony_ci#define DL_DEFIO_WRITE_DISABLE (HZ*60) /* "disable" with long delay */ 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci/* remove these once align.h patch is taken into kernel */ 1008c2ecf20Sopenharmony_ci#define DL_ALIGN_UP(x, a) ALIGN(x, a) 1018c2ecf20Sopenharmony_ci#define DL_ALIGN_DOWN(x, a) ALIGN_DOWN(x, a) 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#endif 104