Skip to content

Commit cd2b89e

Browse files
thomashvmwairlied
authored andcommitted
vmwgfx: Reinstate the update_layout ioctl
We need to redefine a connector as "connected" if it matches a window in the host preferred GUI layout. Otherwise "smart" window managers would turn on Xorg outputs that we don't want to be on. This reinstates the update_layout and adds the following information to the modesetting system. a) Connection status <-> Equivalent to real hardware connection status b) Preferred mode <-> Equivalent to real hardware reading EDID c) Host window position <-> Equivalent to a real hardware scanout address dynamic register. It should be noted that there is no assumption here about what should be displayed and where. Only how to access the host windows. This also bumps minor to signal availability of the new IOCTL. Based on code originally written by Jakob Bornecrantz Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent bc1c4dc commit cd2b89e

5 files changed

Lines changed: 107 additions & 31 deletions

File tree

‎drivers/gpu/drm/vmwgfx/vmwgfx_drv.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@
103103
#define DRM_IOCTL_VMW_PRESENT_READBACK \
104104
DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_PRESENT_READBACK, \
105105
struct drm_vmw_present_readback_arg)
106+
#define DRM_IOCTL_VMW_UPDATE_LAYOUT \
107+
DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_UPDATE_LAYOUT, \
108+
struct drm_vmw_update_layout_arg)
106109

107110
/**
108111
* The core DRM version of this macro doesn't account for
@@ -165,6 +168,9 @@ static struct drm_ioctl_desc vmw_ioctls[] = {
165168
VMW_IOCTL_DEF(VMW_PRESENT_READBACK,
166169
vmw_present_readback_ioctl,
167170
DRM_MASTER | DRM_AUTH | DRM_UNLOCKED),
171+
VMW_IOCTL_DEF(VMW_UPDATE_LAYOUT,
172+
vmw_kms_update_layout_ioctl,
173+
DRM_MASTER | DRM_UNLOCKED),
168174
};
169175

170176
static struct pci_device_id vmw_pci_id_list[] = {

‎drivers/gpu/drm/vmwgfx/vmwgfx_drv.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
#include "ttm/ttm_module.h"
4141
#include "vmwgfx_fence.h"
4242

43-
#define VMWGFX_DRIVER_DATE "20111008"
43+
#define VMWGFX_DRIVER_DATE "20111025"
4444
#define VMWGFX_DRIVER_MAJOR 2
45-
#define VMWGFX_DRIVER_MINOR 2
45+
#define VMWGFX_DRIVER_MINOR 3
4646
#define VMWGFX_DRIVER_PATCHLEVEL 0
4747
#define VMWGFX_FILE_PAGE_OFFSET 0x00100000
4848
#define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
@@ -633,6 +633,8 @@ int vmw_kms_readback(struct vmw_private *dev_priv,
633633
struct drm_vmw_fence_rep __user *user_fence_rep,
634634
struct drm_vmw_rect *clips,
635635
uint32_t num_clips);
636+
int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
637+
struct drm_file *file_priv);
636638

637639
/**
638640
* Overlay control - vmwgfx_overlay.c

‎drivers/gpu/drm/vmwgfx/vmwgfx_kms.c‎

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,8 @@ int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
15171517
du->pref_width = rects[du->unit].w;
15181518
du->pref_height = rects[du->unit].h;
15191519
du->pref_active = true;
1520+
du->gui_x = rects[du->unit].x;
1521+
du->gui_y = rects[du->unit].y;
15201522
} else {
15211523
du->pref_width = 800;
15221524
du->pref_height = 600;
@@ -1572,12 +1574,14 @@ vmw_du_connector_detect(struct drm_connector *connector, bool force)
15721574
uint32_t num_displays;
15731575
struct drm_device *dev = connector->dev;
15741576
struct vmw_private *dev_priv = vmw_priv(dev);
1577+
struct vmw_display_unit *du = vmw_connector_to_du(connector);
15751578

15761579
mutex_lock(&dev_priv->hw_mutex);
15771580
num_displays = vmw_read(dev_priv, SVGA_REG_NUM_DISPLAYS);
15781581
mutex_unlock(&dev_priv->hw_mutex);
15791582

1580-
return ((vmw_connector_to_du(connector)->unit < num_displays) ?
1583+
return ((vmw_connector_to_du(connector)->unit < num_displays &&
1584+
du->pref_active) ?
15811585
connector_status_connected : connector_status_disconnected);
15821586
}
15831587

@@ -1723,3 +1727,63 @@ int vmw_du_connector_set_property(struct drm_connector *connector,
17231727
{
17241728
return 0;
17251729
}
1730+
1731+
1732+
int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
1733+
struct drm_file *file_priv)
1734+
{
1735+
struct vmw_private *dev_priv = vmw_priv(dev);
1736+
struct drm_vmw_update_layout_arg *arg =
1737+
(struct drm_vmw_update_layout_arg *)data;
1738+
struct vmw_master *vmaster = vmw_master(file_priv->master);
1739+
void __user *user_rects;
1740+
struct drm_vmw_rect *rects;
1741+
unsigned rects_size;
1742+
int ret;
1743+
int i;
1744+
struct drm_mode_config *mode_config = &dev->mode_config;
1745+
1746+
ret = ttm_read_lock(&vmaster->lock, true);
1747+
if (unlikely(ret != 0))
1748+
return ret;
1749+
1750+
if (!arg->num_outputs) {
1751+
struct drm_vmw_rect def_rect = {0, 0, 800, 600};
1752+
vmw_du_update_layout(dev_priv, 1, &def_rect);
1753+
goto out_unlock;
1754+
}
1755+
1756+
rects_size = arg->num_outputs * sizeof(struct drm_vmw_rect);
1757+
rects = kzalloc(rects_size, GFP_KERNEL);
1758+
if (unlikely(!rects)) {
1759+
ret = -ENOMEM;
1760+
goto out_unlock;
1761+
}
1762+
1763+
user_rects = (void __user *)(unsigned long)arg->rects;
1764+
ret = copy_from_user(rects, user_rects, rects_size);
1765+
if (unlikely(ret != 0)) {
1766+
DRM_ERROR("Failed to get rects.\n");
1767+
ret = -EFAULT;
1768+
goto out_free;
1769+
}
1770+
1771+
for (i = 0; i < arg->num_outputs; ++i) {
1772+
if (rects->x < 0 ||
1773+
rects->y < 0 ||
1774+
rects->x + rects->w > mode_config->max_width ||
1775+
rects->y + rects->h > mode_config->max_height) {
1776+
DRM_ERROR("Invalid GUI layout.\n");
1777+
ret = -EINVAL;
1778+
goto out_free;
1779+
}
1780+
}
1781+
1782+
vmw_du_update_layout(dev_priv, arg->num_outputs, rects);
1783+
1784+
out_free:
1785+
kfree(rects);
1786+
out_unlock:
1787+
ttm_read_unlock(&vmaster->lock);
1788+
return ret;
1789+
}

‎drivers/gpu/drm/vmwgfx/vmwgfx_kms.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ struct vmw_display_unit {
9696
unsigned pref_height;
9797
bool pref_active;
9898
struct drm_display_mode *pref_mode;
99+
100+
/*
101+
* Gui positioning
102+
*/
103+
int gui_x;
104+
int gui_y;
99105
};
100106

101107
#define vmw_crtc_to_du(x) \
@@ -126,8 +132,7 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
126132
int vmw_du_connector_set_property(struct drm_connector *connector,
127133
struct drm_property *property,
128134
uint64_t val);
129-
int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
130-
struct drm_vmw_rect *rects);
135+
131136

132137
/*
133138
* Legacy display unit functions - vmwgfx_ldu.c

‎include/drm/vmwgfx_drm.h‎

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#define DRM_VMW_FENCE_EVENT 17
5555
#define DRM_VMW_PRESENT 18
5656
#define DRM_VMW_PRESENT_READBACK 19
57-
57+
#define DRM_VMW_UPDATE_LAYOUT 20
5858

5959
/*************************************************************************/
6060
/**
@@ -550,31 +550,6 @@ struct drm_vmw_get_3d_cap_arg {
550550
uint32_t pad64;
551551
};
552552

553-
/*************************************************************************/
554-
/**
555-
* DRM_VMW_UPDATE_LAYOUT - Update layout
556-
*
557-
* Updates the preferred modes and connection status for connectors. The
558-
* command conisits of one drm_vmw_update_layout_arg pointing out a array
559-
* of num_outputs drm_vmw_rect's.
560-
*/
561-
562-
/**
563-
* struct drm_vmw_update_layout_arg
564-
*
565-
* @num_outputs: number of active
566-
* @rects: pointer to array of drm_vmw_rect
567-
*
568-
* Input argument to the DRM_VMW_UPDATE_LAYOUT Ioctl.
569-
*/
570-
571-
struct drm_vmw_update_layout_arg {
572-
uint32_t num_outputs;
573-
uint32_t pad64;
574-
uint64_t rects;
575-
};
576-
577-
578553
/*************************************************************************/
579554
/**
580555
* DRM_VMW_FENCE_WAIT
@@ -788,4 +763,28 @@ struct drm_vmw_present_readback_arg {
788763
uint64_t clips_ptr;
789764
uint64_t fence_rep;
790765
};
766+
767+
/*************************************************************************/
768+
/**
769+
* DRM_VMW_UPDATE_LAYOUT - Update layout
770+
*
771+
* Updates the preferred modes and connection status for connectors. The
772+
* command consists of one drm_vmw_update_layout_arg pointing to an array
773+
* of num_outputs drm_vmw_rect's.
774+
*/
775+
776+
/**
777+
* struct drm_vmw_update_layout_arg
778+
*
779+
* @num_outputs: number of active connectors
780+
* @rects: pointer to array of drm_vmw_rect cast to an uint64_t
781+
*
782+
* Input argument to the DRM_VMW_UPDATE_LAYOUT Ioctl.
783+
*/
784+
struct drm_vmw_update_layout_arg {
785+
uint32_t num_outputs;
786+
uint32_t pad64;
787+
uint64_t rects;
788+
};
789+
791790
#endif

0 commit comments

Comments
 (0)