|
1 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
2 | 2 |
|
| 3 | +#include <linux/anon_inodes.h> |
3 | 4 | #include <linux/dma-mapping.h> |
4 | 5 | #include <linux/io.h> |
5 | 6 | #include <linux/iopoll.h> |
| 7 | +#include <linux/file.h> |
6 | 8 | #include <linux/of.h> |
7 | 9 | #include <linux/platform_device.h> |
| 10 | +#include <linux/types.h> |
| 11 | + |
| 12 | +#include <asm/current.h> |
| 13 | + |
8 | 14 | #include <drm/drm_atomic.h> |
9 | 15 | #include <drm/drm_atomic_helper.h> |
10 | 16 | #include <drm/drm_damage_helper.h> |
|
13 | 19 | #include <drm/drm_edid.h> |
14 | 20 | #include <drm/drm_fb_dma_helper.h> |
15 | 21 | #include <drm/drm_fbdev_generic.h> |
| 22 | +#include <drm/drm_file.h> |
16 | 23 | #include <drm/drm_framebuffer.h> |
17 | 24 | #include <drm/drm_gem_atomic_helper.h> |
18 | 25 | #include <drm/drm_gem_dma_helper.h> |
|
73 | 80 | #define GEN_RD_CMD_BUSY BIT(6) |
74 | 81 | #define CMD_PKT_STATUS_TIMEOUT_US 20000 |
75 | 82 |
|
76 | | -DEFINE_DRM_GEM_DMA_FOPS(adp_fops); |
| 83 | +static int adp_open(struct inode *inode, struct file *filp) |
| 84 | +{ |
| 85 | + /* |
| 86 | + * The modesetting driver does not check the non-desktop connector |
| 87 | + * property and keeps the device open and locked. If the touchbar daemon |
| 88 | + * opens the device first modesetting breaks the whole X session. |
| 89 | + * Simply refuse to open the device for X11 server processes as |
| 90 | + * workaround. |
| 91 | + */ |
| 92 | + if (current->comm[0] == 'X') |
| 93 | + return -EBUSY; |
| 94 | + |
| 95 | + return drm_open(inode, filp); |
| 96 | +} |
| 97 | + |
| 98 | +static const struct file_operations adp_fops = { |
| 99 | + .owner = THIS_MODULE, |
| 100 | + .open = adp_open, |
| 101 | + .release = drm_release, |
| 102 | + .unlocked_ioctl = drm_ioctl, |
| 103 | + .compat_ioctl = drm_compat_ioctl, |
| 104 | + .poll = drm_poll, |
| 105 | + .read = drm_read, |
| 106 | + .llseek = noop_llseek, |
| 107 | + .mmap = drm_gem_mmap, |
| 108 | + DRM_GEM_DMA_UNMAPPED_AREA_FOPS |
| 109 | +}; |
77 | 110 |
|
78 | 111 | static int adp_drm_gem_dumb_create(struct drm_file *file_priv, |
79 | 112 | struct drm_device *drm, |
|
0 commit comments