| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2012 Red Hat |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * Copyright (C) 2009 Roberto De Ioris <roberto@unbit.it> |
|---|
| 6 | 7 | * Copyright (C) 2009 Jaya Kumar <jayakumar.lkml@gmail.com> |
|---|
| 7 | 8 | * 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 | 9 | */ |
|---|
| 13 | 10 | |
|---|
| 14 | 11 | #ifndef UDL_DRV_H |
|---|
| 15 | 12 | #define UDL_DRV_H |
|---|
| 16 | 13 | |
|---|
| 17 | | -#include <linux/usb.h> |
|---|
| 18 | | -#include <drm/drm_gem.h> |
|---|
| 19 | 14 | #include <linux/mm_types.h> |
|---|
| 15 | +#include <linux/usb.h> |
|---|
| 16 | + |
|---|
| 17 | +#include <drm/drm_device.h> |
|---|
| 18 | +#include <drm/drm_framebuffer.h> |
|---|
| 19 | +#include <drm/drm_gem.h> |
|---|
| 20 | +#include <drm/drm_simple_kms_helper.h> |
|---|
| 21 | + |
|---|
| 22 | +struct drm_mode_create_dumb; |
|---|
| 20 | 23 | |
|---|
| 21 | 24 | #define DRIVER_NAME "udl" |
|---|
| 22 | 25 | #define DRIVER_DESC "DisplayLink" |
|---|
| .. | .. |
|---|
| 25 | 28 | #define DRIVER_MAJOR 0 |
|---|
| 26 | 29 | #define DRIVER_MINOR 0 |
|---|
| 27 | 30 | #define DRIVER_PATCHLEVEL 1 |
|---|
| 28 | | - |
|---|
| 29 | | -#define UDL_BO_CACHEABLE (1 << 0) |
|---|
| 30 | | -#define UDL_BO_WC (1 << 1) |
|---|
| 31 | 31 | |
|---|
| 32 | 32 | struct udl_device; |
|---|
| 33 | 33 | |
|---|
| .. | .. |
|---|
| 47 | 47 | size_t size; |
|---|
| 48 | 48 | }; |
|---|
| 49 | 49 | |
|---|
| 50 | | -struct udl_fbdev; |
|---|
| 51 | | - |
|---|
| 52 | 50 | struct udl_device { |
|---|
| 53 | 51 | struct drm_device drm; |
|---|
| 54 | 52 | struct device *dev; |
|---|
| 53 | + struct device *dmadev; |
|---|
| 55 | 54 | struct usb_device *udev; |
|---|
| 56 | | - struct drm_crtc *crtc; |
|---|
| 55 | + |
|---|
| 56 | + struct drm_simple_display_pipe display_pipe; |
|---|
| 57 | 57 | |
|---|
| 58 | 58 | struct mutex gem_lock; |
|---|
| 59 | 59 | |
|---|
| 60 | 60 | int sku_pixel_limit; |
|---|
| 61 | 61 | |
|---|
| 62 | 62 | struct urb_list urbs; |
|---|
| 63 | | - atomic_t lost_pixels; /* 1 = a render op failed. Need screen refresh */ |
|---|
| 64 | 63 | |
|---|
| 65 | | - struct udl_fbdev *fbdev; |
|---|
| 66 | 64 | char mode_buf[1024]; |
|---|
| 67 | 65 | uint32_t mode_buf_len; |
|---|
| 68 | | - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */ |
|---|
| 69 | | - atomic_t bytes_identical; /* saved effort with backbuffer comparison */ |
|---|
| 70 | | - atomic_t bytes_sent; /* to usb, after compression including overhead */ |
|---|
| 71 | | - atomic_t cpu_kcycles_used; /* transpired during pixel processing */ |
|---|
| 72 | 66 | }; |
|---|
| 73 | 67 | |
|---|
| 74 | 68 | #define to_udl(x) container_of(x, struct udl_device, drm) |
|---|
| 75 | 69 | |
|---|
| 76 | | -struct udl_gem_object { |
|---|
| 77 | | - struct drm_gem_object base; |
|---|
| 78 | | - struct page **pages; |
|---|
| 79 | | - void *vmapping; |
|---|
| 80 | | - struct sg_table *sg; |
|---|
| 81 | | - unsigned int flags; |
|---|
| 82 | | -}; |
|---|
| 83 | | - |
|---|
| 84 | | -#define to_udl_bo(x) container_of(x, struct udl_gem_object, base) |
|---|
| 85 | | - |
|---|
| 86 | | -struct udl_framebuffer { |
|---|
| 87 | | - struct drm_framebuffer base; |
|---|
| 88 | | - struct udl_gem_object *obj; |
|---|
| 89 | | - bool active_16; /* active on the 16-bit channel */ |
|---|
| 90 | | -}; |
|---|
| 91 | | - |
|---|
| 92 | | -#define to_udl_fb(x) container_of(x, struct udl_framebuffer, base) |
|---|
| 93 | | - |
|---|
| 94 | 70 | /* modeset */ |
|---|
| 95 | 71 | int udl_modeset_init(struct drm_device *dev); |
|---|
| 96 | | -void udl_modeset_restore(struct drm_device *dev); |
|---|
| 97 | | -void udl_modeset_cleanup(struct drm_device *dev); |
|---|
| 98 | | -int udl_connector_init(struct drm_device *dev, struct drm_encoder *encoder); |
|---|
| 99 | | - |
|---|
| 100 | | -struct drm_encoder *udl_encoder_init(struct drm_device *dev); |
|---|
| 72 | +struct drm_connector *udl_connector_init(struct drm_device *dev); |
|---|
| 101 | 73 | |
|---|
| 102 | 74 | struct urb *udl_get_urb(struct drm_device *dev); |
|---|
| 103 | 75 | |
|---|
| .. | .. |
|---|
| 105 | 77 | void udl_urb_completion(struct urb *urb); |
|---|
| 106 | 78 | |
|---|
| 107 | 79 | int udl_init(struct udl_device *udl); |
|---|
| 108 | | -void udl_fini(struct drm_device *dev); |
|---|
| 109 | | - |
|---|
| 110 | | -int udl_fbdev_init(struct drm_device *dev); |
|---|
| 111 | | -void udl_fbdev_cleanup(struct drm_device *dev); |
|---|
| 112 | | -void udl_fbdev_unplug(struct drm_device *dev); |
|---|
| 113 | | -struct drm_framebuffer * |
|---|
| 114 | | -udl_fb_user_fb_create(struct drm_device *dev, |
|---|
| 115 | | - struct drm_file *file, |
|---|
| 116 | | - const struct drm_mode_fb_cmd2 *mode_cmd); |
|---|
| 117 | 80 | |
|---|
| 118 | 81 | int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr, |
|---|
| 119 | 82 | const char *front, char **urb_buf_ptr, |
|---|
| 120 | | - u32 byte_offset, u32 device_byte_offset, u32 byte_width, |
|---|
| 121 | | - int *ident_ptr, int *sent_ptr); |
|---|
| 122 | | - |
|---|
| 123 | | -int udl_dumb_create(struct drm_file *file_priv, |
|---|
| 124 | | - struct drm_device *dev, |
|---|
| 125 | | - struct drm_mode_create_dumb *args); |
|---|
| 126 | | -int udl_gem_mmap(struct drm_file *file_priv, struct drm_device *dev, |
|---|
| 127 | | - uint32_t handle, uint64_t *offset); |
|---|
| 128 | | - |
|---|
| 129 | | -void udl_gem_free_object(struct drm_gem_object *gem_obj); |
|---|
| 130 | | -struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev, |
|---|
| 131 | | - size_t size); |
|---|
| 132 | | -struct dma_buf *udl_gem_prime_export(struct drm_device *dev, |
|---|
| 133 | | - struct drm_gem_object *obj, int flags); |
|---|
| 134 | | -struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev, |
|---|
| 135 | | - struct dma_buf *dma_buf); |
|---|
| 136 | | - |
|---|
| 137 | | -int udl_gem_get_pages(struct udl_gem_object *obj); |
|---|
| 138 | | -void udl_gem_put_pages(struct udl_gem_object *obj); |
|---|
| 139 | | -int udl_gem_vmap(struct udl_gem_object *obj); |
|---|
| 140 | | -void udl_gem_vunmap(struct udl_gem_object *obj); |
|---|
| 141 | | -int udl_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); |
|---|
| 142 | | -vm_fault_t udl_gem_fault(struct vm_fault *vmf); |
|---|
| 143 | | - |
|---|
| 144 | | -int udl_handle_damage(struct udl_framebuffer *fb, int x, int y, |
|---|
| 145 | | - int width, int height); |
|---|
| 83 | + u32 byte_offset, u32 device_byte_offset, u32 byte_width); |
|---|
| 146 | 84 | |
|---|
| 147 | 85 | int udl_drop_usb(struct drm_device *dev); |
|---|
| 148 | 86 | |
|---|
| .. | .. |
|---|
| 156 | 94 | #define CMD_WRITE_COPY16 "\xAF\x6A" /**< 16 bit copy command. */ |
|---|
| 157 | 95 | #define CMD_WRITE_RLX16 "\xAF\x6B" /**< 16 bit extended run length command. */ |
|---|
| 158 | 96 | |
|---|
| 97 | +/* On/Off for driving the DisplayLink framebuffer to the display */ |
|---|
| 98 | +#define UDL_REG_BLANK_MODE 0x1f |
|---|
| 99 | + |
|---|
| 100 | +#define UDL_BLANK_MODE_ON 0x00 /* hsync and vsync on, visible */ |
|---|
| 101 | +#define UDL_BLANK_MODE_BLANKED 0x01 /* hsync and vsync on, blanked */ |
|---|
| 102 | +#define UDL_BLANK_MODE_VSYNC_OFF 0x03 /* vsync off, blanked */ |
|---|
| 103 | +#define UDL_BLANK_MODE_HSYNC_OFF 0x05 /* hsync off, blanked */ |
|---|
| 104 | +#define UDL_BLANK_MODE_POWERDOWN 0x07 /* powered off; requires modeset */ |
|---|
| 105 | + |
|---|
| 159 | 106 | #endif |
|---|