Dave Airlie | 5320918 | 2010-12-15 07:14:24 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Red Hat |
| 3 | * |
| 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> |
| 8 | * |
| 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. |
| 12 | */ |
| 13 | |
| 14 | #ifndef UDL_DRV_H |
| 15 | #define UDL_DRV_H |
| 16 | |
| 17 | #include <linux/usb.h> |
| 18 | |
| 19 | #define DRIVER_NAME "udl" |
| 20 | #define DRIVER_DESC "DisplayLink" |
| 21 | #define DRIVER_DATE "20120220" |
| 22 | |
| 23 | #define DRIVER_MAJOR 0 |
| 24 | #define DRIVER_MINOR 0 |
| 25 | #define DRIVER_PATCHLEVEL 1 |
| 26 | |
| 27 | struct udl_device; |
| 28 | |
| 29 | struct urb_node { |
| 30 | struct list_head entry; |
| 31 | struct udl_device *dev; |
| 32 | struct delayed_work release_urb_work; |
| 33 | struct urb *urb; |
| 34 | }; |
| 35 | |
| 36 | struct urb_list { |
| 37 | struct list_head list; |
| 38 | spinlock_t lock; |
| 39 | struct semaphore limit_sem; |
| 40 | int available; |
| 41 | int count; |
| 42 | size_t size; |
| 43 | }; |
| 44 | |
| 45 | struct udl_fbdev; |
| 46 | |
| 47 | struct udl_device { |
| 48 | struct device *dev; |
| 49 | struct drm_device *ddev; |
| 50 | |
| 51 | int sku_pixel_limit; |
| 52 | |
| 53 | struct urb_list urbs; |
| 54 | atomic_t lost_pixels; /* 1 = a render op failed. Need screen refresh */ |
| 55 | |
| 56 | struct udl_fbdev *fbdev; |
| 57 | char mode_buf[1024]; |
| 58 | uint32_t mode_buf_len; |
| 59 | atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */ |
| 60 | atomic_t bytes_identical; /* saved effort with backbuffer comparison */ |
| 61 | atomic_t bytes_sent; /* to usb, after compression including overhead */ |
| 62 | atomic_t cpu_kcycles_used; /* transpired during pixel processing */ |
| 63 | }; |
| 64 | |
| 65 | struct udl_gem_object { |
| 66 | struct drm_gem_object base; |
| 67 | struct page **pages; |
| 68 | void *vmapping; |
| 69 | }; |
| 70 | |
| 71 | #define to_udl_bo(x) container_of(x, struct udl_gem_object, base) |
| 72 | |
| 73 | struct udl_framebuffer { |
| 74 | struct drm_framebuffer base; |
| 75 | struct udl_gem_object *obj; |
| 76 | bool active_16; /* active on the 16-bit channel */ |
| 77 | }; |
| 78 | |
| 79 | #define to_udl_fb(x) container_of(x, struct udl_framebuffer, base) |
| 80 | |
| 81 | /* modeset */ |
| 82 | int udl_modeset_init(struct drm_device *dev); |
| 83 | void udl_modeset_cleanup(struct drm_device *dev); |
| 84 | int udl_connector_init(struct drm_device *dev, struct drm_encoder *encoder); |
| 85 | |
| 86 | struct drm_encoder *udl_encoder_init(struct drm_device *dev); |
| 87 | |
| 88 | struct urb *udl_get_urb(struct drm_device *dev); |
| 89 | |
| 90 | int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len); |
| 91 | void udl_urb_completion(struct urb *urb); |
| 92 | |
| 93 | int udl_driver_load(struct drm_device *dev, unsigned long flags); |
| 94 | int udl_driver_unload(struct drm_device *dev); |
| 95 | |
| 96 | int udl_fbdev_init(struct drm_device *dev); |
| 97 | void udl_fbdev_cleanup(struct drm_device *dev); |
| 98 | void udl_fbdev_unplug(struct drm_device *dev); |
| 99 | struct drm_framebuffer * |
| 100 | udl_fb_user_fb_create(struct drm_device *dev, |
| 101 | struct drm_file *file, |
| 102 | struct drm_mode_fb_cmd2 *mode_cmd); |
| 103 | |
| 104 | int udl_render_hline(struct drm_device *dev, int bpp, struct urb **urb_ptr, |
| 105 | const char *front, char **urb_buf_ptr, |
| 106 | u32 byte_offset, u32 byte_width, |
| 107 | int *ident_ptr, int *sent_ptr); |
| 108 | |
| 109 | int udl_dumb_create(struct drm_file *file_priv, |
| 110 | struct drm_device *dev, |
| 111 | struct drm_mode_create_dumb *args); |
| 112 | int udl_gem_mmap(struct drm_file *file_priv, struct drm_device *dev, |
| 113 | uint32_t handle, uint64_t *offset); |
| 114 | int udl_dumb_destroy(struct drm_file *file_priv, struct drm_device *dev, |
| 115 | uint32_t handle); |
| 116 | |
| 117 | int udl_gem_init_object(struct drm_gem_object *obj); |
| 118 | void udl_gem_free_object(struct drm_gem_object *gem_obj); |
| 119 | struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev, |
| 120 | size_t size); |
| 121 | |
| 122 | int udl_gem_vmap(struct udl_gem_object *obj); |
| 123 | void udl_gem_vunmap(struct udl_gem_object *obj); |
Konstantin Khlebnikov | fa9e855 | 2012-03-31 13:29:25 +0400 | [diff] [blame^] | 124 | int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); |
Dave Airlie | 5320918 | 2010-12-15 07:14:24 +1000 | [diff] [blame] | 125 | int udl_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); |
| 126 | |
| 127 | int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, |
| 128 | int width, int height); |
| 129 | |
| 130 | int udl_drop_usb(struct drm_device *dev); |
| 131 | |
| 132 | #define CMD_WRITE_RAW8 "\xAF\x60" /**< 8 bit raw write command. */ |
| 133 | #define CMD_WRITE_RL8 "\xAF\x61" /**< 8 bit run length command. */ |
| 134 | #define CMD_WRITE_COPY8 "\xAF\x62" /**< 8 bit copy command. */ |
| 135 | #define CMD_WRITE_RLX8 "\xAF\x63" /**< 8 bit extended run length command. */ |
| 136 | |
| 137 | #define CMD_WRITE_RAW16 "\xAF\x68" /**< 16 bit raw write command. */ |
| 138 | #define CMD_WRITE_RL16 "\xAF\x69" /**< 16 bit run length command. */ |
| 139 | #define CMD_WRITE_COPY16 "\xAF\x6A" /**< 16 bit copy command. */ |
| 140 | #define CMD_WRITE_RLX16 "\xAF\x6B" /**< 16 bit extended run length command. */ |
| 141 | |
| 142 | #endif |