1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2012 Red Hat
4 *
5 * based in parts on udlfb.c:
6 * Copyright (C) 2009 Roberto De Ioris <roberto@unbit.it>
7 * Copyright (C) 2009 Jaya Kumar <jayakumar.lkml@gmail.com>
8 * Copyright (C) 2009 Bernie Thompson <bernie@plugable.com>
9 */
10
11 #ifndef UDL_DRV_H
12 #define UDL_DRV_H
13
14 #include <linux/mm_types.h>
15 #include <linux/usb.h>
16
17 #include <drm/drm_connector.h>
18 #include <drm/drm_crtc.h>
19 #include <drm/drm_device.h>
20 #include <drm/drm_encoder.h>
21 #include <drm/drm_framebuffer.h>
22 #include <drm/drm_gem.h>
23 #include <drm/drm_plane.h>
24
25 struct drm_mode_create_dumb;
26
27 #define DRIVER_NAME "udl"
28 #define DRIVER_DESC "DisplayLink"
29 #define DRIVER_DATE "20120220"
30
31 #define DRIVER_MAJOR 0
32 #define DRIVER_MINOR 0
33 #define DRIVER_PATCHLEVEL 1
34
35 struct udl_device;
36
37 struct urb_node {
38 struct list_head entry;
39 struct udl_device *dev;
40 struct urb *urb;
41 };
42
43 struct urb_list {
44 struct list_head list;
45 spinlock_t lock;
46 wait_queue_head_t sleep;
47 int available;
48 int count;
49 size_t size;
50 };
51
52 struct udl_device {
53 struct drm_device drm;
54 struct device *dev;
55 struct device *dmadev;
56
57 struct drm_plane primary_plane;
58 struct drm_crtc crtc;
59 struct drm_encoder encoder;
60 struct drm_connector connector;
61
62 struct mutex gem_lock;
63
64 int sku_pixel_limit;
65
66 struct urb_list urbs;
67 };
68
69 #define to_udl(x) container_of(x, struct udl_device, drm)
70
udl_to_usb_device(struct udl_device * udl)71 static inline struct usb_device *udl_to_usb_device(struct udl_device *udl)
72 {
73 return interface_to_usbdev(to_usb_interface(udl->drm.dev));
74 }
75
76 /* modeset */
77 int udl_modeset_init(struct drm_device *dev);
78 struct drm_connector *udl_connector_init(struct drm_device *dev);
79
80 struct urb *udl_get_urb(struct drm_device *dev);
81
82 int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len);
83 void udl_sync_pending_urbs(struct drm_device *dev);
84 void udl_urb_completion(struct urb *urb);
85
86 int udl_init(struct udl_device *udl);
87
88 int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr,
89 const char *front, char **urb_buf_ptr,
90 u32 byte_offset, u32 device_byte_offset, u32 byte_width);
91
92 int udl_drop_usb(struct drm_device *dev);
93 int udl_select_std_channel(struct udl_device *udl);
94
95 #endif
96