Linux 4.2.1
[linux/fpc-iii.git] / drivers / gpu / drm / udl / udl_drv.h
blob80adbac82bdedcfb99db9164575ffa6b8787a9f8
1 /*
2 * Copyright (C) 2012 Red Hat
4 * based in parts on udlfb.c:
5 * Copyright (C) 2009 Roberto De Ioris <roberto@unbit.it>
6 * Copyright (C) 2009 Jaya Kumar <jayakumar.lkml@gmail.com>
7 * Copyright (C) 2009 Bernie Thompson <bernie@plugable.com>
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License v2. See the file COPYING in the main directory of this archive for
11 * more details.
14 #ifndef UDL_DRV_H
15 #define UDL_DRV_H
17 #include <linux/usb.h>
18 #include <drm/drm_gem.h>
20 #define DRIVER_NAME "udl"
21 #define DRIVER_DESC "DisplayLink"
22 #define DRIVER_DATE "20120220"
24 #define DRIVER_MAJOR 0
25 #define DRIVER_MINOR 0
26 #define DRIVER_PATCHLEVEL 1
28 #define UDL_BO_CACHEABLE (1 << 0)
29 #define UDL_BO_WC (1 << 1)
31 struct udl_device;
33 struct urb_node {
34 struct list_head entry;
35 struct udl_device *dev;
36 struct delayed_work release_urb_work;
37 struct urb *urb;
40 struct urb_list {
41 struct list_head list;
42 spinlock_t lock;
43 struct semaphore limit_sem;
44 int available;
45 int count;
46 size_t size;
49 struct udl_fbdev;
51 struct udl_device {
52 struct device *dev;
53 struct drm_device *ddev;
54 struct usb_device *udev;
56 int sku_pixel_limit;
58 struct urb_list urbs;
59 atomic_t lost_pixels; /* 1 = a render op failed. Need screen refresh */
61 struct udl_fbdev *fbdev;
62 char mode_buf[1024];
63 uint32_t mode_buf_len;
64 atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
65 atomic_t bytes_identical; /* saved effort with backbuffer comparison */
66 atomic_t bytes_sent; /* to usb, after compression including overhead */
67 atomic_t cpu_kcycles_used; /* transpired during pixel processing */
70 struct udl_gem_object {
71 struct drm_gem_object base;
72 struct page **pages;
73 void *vmapping;
74 struct sg_table *sg;
75 unsigned int flags;
78 #define to_udl_bo(x) container_of(x, struct udl_gem_object, base)
80 struct udl_framebuffer {
81 struct drm_framebuffer base;
82 struct udl_gem_object *obj;
83 bool active_16; /* active on the 16-bit channel */
84 int x1, y1, x2, y2; /* dirty rect */
85 spinlock_t dirty_lock;
88 #define to_udl_fb(x) container_of(x, struct udl_framebuffer, base)
90 /* modeset */
91 int udl_modeset_init(struct drm_device *dev);
92 void udl_modeset_cleanup(struct drm_device *dev);
93 int udl_connector_init(struct drm_device *dev, struct drm_encoder *encoder);
95 struct drm_encoder *udl_encoder_init(struct drm_device *dev);
97 struct urb *udl_get_urb(struct drm_device *dev);
99 int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len);
100 void udl_urb_completion(struct urb *urb);
102 int udl_driver_load(struct drm_device *dev, unsigned long flags);
103 int udl_driver_unload(struct drm_device *dev);
105 int udl_fbdev_init(struct drm_device *dev);
106 void udl_fbdev_cleanup(struct drm_device *dev);
107 void udl_fbdev_unplug(struct drm_device *dev);
108 struct drm_framebuffer *
109 udl_fb_user_fb_create(struct drm_device *dev,
110 struct drm_file *file,
111 struct drm_mode_fb_cmd2 *mode_cmd);
113 int udl_render_hline(struct drm_device *dev, int bpp, struct urb **urb_ptr,
114 const char *front, char **urb_buf_ptr,
115 u32 byte_offset, u32 device_byte_offset, u32 byte_width,
116 int *ident_ptr, int *sent_ptr);
118 int udl_dumb_create(struct drm_file *file_priv,
119 struct drm_device *dev,
120 struct drm_mode_create_dumb *args);
121 int udl_gem_mmap(struct drm_file *file_priv, struct drm_device *dev,
122 uint32_t handle, uint64_t *offset);
124 void udl_gem_free_object(struct drm_gem_object *gem_obj);
125 struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev,
126 size_t size);
127 struct dma_buf *udl_gem_prime_export(struct drm_device *dev,
128 struct drm_gem_object *obj, int flags);
129 struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,
130 struct dma_buf *dma_buf);
132 int udl_gem_get_pages(struct udl_gem_object *obj);
133 void udl_gem_put_pages(struct udl_gem_object *obj);
134 int udl_gem_vmap(struct udl_gem_object *obj);
135 void udl_gem_vunmap(struct udl_gem_object *obj);
136 int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
137 int udl_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
139 int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
140 int width, int height);
142 int udl_drop_usb(struct drm_device *dev);
144 #define CMD_WRITE_RAW8 "\xAF\x60" /**< 8 bit raw write command. */
145 #define CMD_WRITE_RL8 "\xAF\x61" /**< 8 bit run length command. */
146 #define CMD_WRITE_COPY8 "\xAF\x62" /**< 8 bit copy command. */
147 #define CMD_WRITE_RLX8 "\xAF\x63" /**< 8 bit extended run length command. */
149 #define CMD_WRITE_RAW16 "\xAF\x68" /**< 16 bit raw write command. */
150 #define CMD_WRITE_RL16 "\xAF\x69" /**< 16 bit run length command. */
151 #define CMD_WRITE_COPY16 "\xAF\x6A" /**< 16 bit copy command. */
152 #define CMD_WRITE_RLX16 "\xAF\x6B" /**< 16 bit extended run length command. */
154 #endif