xref: /linux/drivers/gpu/drm/udl/udl_drv.h (revision acbf6de674ef7b1b5870b25e7b3c695bf84273d0)
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_connector {
53 	struct drm_connector connector;
54 	/* last udl_detect edid */
55 	struct edid *edid;
56 };
57 
58 static inline struct udl_connector *to_udl_connector(struct drm_connector *connector)
59 {
60 	return container_of(connector, struct udl_connector, connector);
61 }
62 
63 struct udl_device {
64 	struct drm_device drm;
65 	struct device *dev;
66 	struct device *dmadev;
67 
68 	struct drm_plane primary_plane;
69 	struct drm_crtc crtc;
70 	struct drm_encoder encoder;
71 
72 	struct mutex gem_lock;
73 
74 	int sku_pixel_limit;
75 
76 	struct urb_list urbs;
77 };
78 
79 #define to_udl(x) container_of(x, struct udl_device, drm)
80 
81 static inline struct usb_device *udl_to_usb_device(struct udl_device *udl)
82 {
83 	return interface_to_usbdev(to_usb_interface(udl->drm.dev));
84 }
85 
86 /* modeset */
87 int udl_modeset_init(struct drm_device *dev);
88 struct drm_connector *udl_connector_init(struct drm_device *dev);
89 
90 struct urb *udl_get_urb(struct drm_device *dev);
91 
92 int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len);
93 void udl_sync_pending_urbs(struct drm_device *dev);
94 void udl_urb_completion(struct urb *urb);
95 
96 int udl_init(struct udl_device *udl);
97 
98 int udl_render_hline(struct drm_device *dev, int log_bpp, struct urb **urb_ptr,
99 		     const char *front, char **urb_buf_ptr,
100 		     u32 byte_offset, u32 device_byte_offset, u32 byte_width);
101 
102 int udl_drop_usb(struct drm_device *dev);
103 int udl_select_std_channel(struct udl_device *udl);
104 
105 #endif
106