Subversion Repositories Kolibri OS

Rev

Rev 4570 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4570 Rev 5078
Line 116... Line 116...
116
            *dst++ = *image++;
116
            *dst++ = *image++;
117
        for( ; j < 64; j++)
117
        for( ; j < 64; j++)
118
            *dst++ = 0;
118
            *dst++ = 0;
119
    }
119
    }
120
    for(i = 0; i < 64*(64-32); i++)
120
    for(i = 0; i < 64*(64-32); i++)
121
        *image++ = 0;
121
        *dst++ = 0;
Line 122... Line 122...
122
 
122
 
123
	cmd->cmd = cpu_to_le32(SVGA_CMD_DEFINE_ALPHA_CURSOR);
123
	cmd->cmd = cpu_to_le32(SVGA_CMD_DEFINE_ALPHA_CURSOR);
124
	cmd->cursor.id = cpu_to_le32(0);
124
	cmd->cursor.id = cpu_to_le32(0);
125
	cmd->cursor.width = cpu_to_le32(width);
125
	cmd->cursor.width = cpu_to_le32(width);
Line 146... Line 146...
146
	int ret;
146
	int ret;
Line 147... Line 147...
147
 
147
 
148
	kmap_offset = 0;
148
	kmap_offset = 0;
Line 149... Line 149...
149
	kmap_num = (width*height*4 + PAGE_SIZE - 1) >> PAGE_SHIFT;
149
	kmap_num = (width*height*4 + PAGE_SIZE - 1) >> PAGE_SHIFT;
150
 
150
 
151
	ret = ttm_bo_reserve(&dmabuf->base, true, false, false, 0);
151
	ret = ttm_bo_reserve(&dmabuf->base, true, false, false, NULL);
152
	if (unlikely(ret != 0)) {
152
	if (unlikely(ret != 0)) {
153
		DRM_ERROR("reserve failed\n");
153
		DRM_ERROR("reserve failed\n");
Line 198... Line 198...
198
	 * cursor_set function, especially vmw_cursor_update_position looks
198
	 * cursor_set function, especially vmw_cursor_update_position looks
199
	 * suspicious. For now take the easy route and reacquire all locks. We
199
	 * suspicious. For now take the easy route and reacquire all locks. We
200
	 * can do this since the caller in the drm core doesn't check anything
200
	 * can do this since the caller in the drm core doesn't check anything
201
	 * which is protected by any looks.
201
	 * which is protected by any looks.
202
	 */
202
	 */
203
	mutex_unlock(&crtc->mutex);
203
	drm_modeset_unlock(&crtc->mutex);
204
	drm_modeset_lock_all(dev_priv->dev);
204
	drm_modeset_lock_all(dev_priv->dev);
Line 205... Line 205...
205
 
205
 
206
	/* A lot of the code assumes this */
206
	/* A lot of the code assumes this */
207
	if (handle && (width != 64 || height != 64)) {
207
	if (handle && (width != 64 || height != 64)) {
Line 263... Line 263...
263
				   du->cursor_y + du->hotspot_y);
263
				   du->cursor_y + du->hotspot_y);
Line 264... Line 264...
264
 
264
 
265
	ret = 0;
265
	ret = 0;
266
out:
266
out:
267
	drm_modeset_unlock_all(dev_priv->dev);
267
	drm_modeset_unlock_all(dev_priv->dev);
Line 268... Line 268...
268
	mutex_lock(&crtc->mutex);
268
	drm_modeset_lock(&crtc->mutex, NULL);
269
 
269
 
Line 270... Line 270...
270
	return ret;
270
	return ret;
Line 284... Line 284...
284
	 * cursor_set function, especially vmw_cursor_update_position looks
284
	 * cursor_set function, especially vmw_cursor_update_position looks
285
	 * suspicious. For now take the easy route and reacquire all locks. We
285
	 * suspicious. For now take the easy route and reacquire all locks. We
286
	 * can do this since the caller in the drm core doesn't check anything
286
	 * can do this since the caller in the drm core doesn't check anything
287
	 * which is protected by any looks.
287
	 * which is protected by any looks.
288
	 */
288
	 */
289
	mutex_unlock(&crtc->mutex);
289
	drm_modeset_unlock(&crtc->mutex);
290
	drm_modeset_lock_all(dev_priv->dev);
290
	drm_modeset_lock_all(dev_priv->dev);
Line 291... Line 291...
291
 
291
 
292
	vmw_cursor_update_position(dev_priv, shown,
292
	vmw_cursor_update_position(dev_priv, shown,
293
				   du->cursor_x + du->hotspot_x,
293
				   du->cursor_x + du->hotspot_x,
Line 294... Line 294...
294
				   du->cursor_y + du->hotspot_y);
294
				   du->cursor_y + du->hotspot_y);
295
 
295
 
Line 296... Line 296...
296
	drm_modeset_unlock_all(dev_priv->dev);
296
	drm_modeset_unlock_all(dev_priv->dev);
297
	mutex_lock(&crtc->mutex);
297
	drm_modeset_lock(&crtc->mutex, NULL);
Line 298... Line 298...
298
 
298
 
Line 354... Line 354...
354
	}
354
	}
Line 355... Line 355...
355
 
355
 
356
	kmap_offset = cmd->dma.guest.ptr.offset >> PAGE_SHIFT;
356
	kmap_offset = cmd->dma.guest.ptr.offset >> PAGE_SHIFT;
Line 357... Line 357...
357
	kmap_num = (64*64*4) >> PAGE_SHIFT;
357
	kmap_num = (64*64*4) >> PAGE_SHIFT;
358
 
358
 
359
	ret = ttm_bo_reserve(bo, true, false, false, 0);
359
	ret = ttm_bo_reserve(bo, true, false, false, NULL);
360
	if (unlikely(ret != 0)) {
360
	if (unlikely(ret != 0)) {
361
		DRM_ERROR("reserve failed\n");
361
		DRM_ERROR("reserve failed\n");
Line 476... Line 476...
476
	SVGASignedRect *blits;
476
	SVGASignedRect *blits;
Line 477... Line 477...
477
 
477
 
478
	num_units = 0;
478
	num_units = 0;
479
	list_for_each_entry(crtc, &dev_priv->dev->mode_config.crtc_list,
479
	list_for_each_entry(crtc, &dev_priv->dev->mode_config.crtc_list,
480
			    head) {
480
			    head) {
481
		if (crtc->fb != &framebuffer->base)
481
		if (crtc->primary->fb != &framebuffer->base)
482
			continue;
482
			continue;
483
		units[num_units++] = vmw_crtc_to_du(crtc);
483
		units[num_units++] = vmw_crtc_to_du(crtc);
Line 484... Line 484...
484
	}
484
	}
Line 604... Line 604...
604
				  unsigned flags, unsigned color,
604
				  unsigned flags, unsigned color,
605
				  struct drm_clip_rect *clips,
605
				  struct drm_clip_rect *clips,
606
				  unsigned num_clips)
606
				  unsigned num_clips)
607
{
607
{
608
	struct vmw_private *dev_priv = vmw_priv(framebuffer->dev);
608
	struct vmw_private *dev_priv = vmw_priv(framebuffer->dev);
609
	struct vmw_master *vmaster = vmw_master(file_priv->master);
-
 
610
	struct vmw_framebuffer_surface *vfbs =
609
	struct vmw_framebuffer_surface *vfbs =
611
		vmw_framebuffer_to_vfbs(framebuffer);
610
		vmw_framebuffer_to_vfbs(framebuffer);
612
	struct drm_clip_rect norect;
611
	struct drm_clip_rect norect;
613
	int ret, inc = 1;
612
	int ret, inc = 1;
Line 619... Line 618...
619
	if (!dev_priv->sou_priv)
618
	if (!dev_priv->sou_priv)
620
		return -EINVAL;
619
		return -EINVAL;
Line 621... Line 620...
621
 
620
 
Line 622... Line 621...
622
	drm_modeset_lock_all(dev_priv->dev);
621
	drm_modeset_lock_all(dev_priv->dev);
623
 
622
 
624
	ret = ttm_read_lock(&vmaster->lock, true);
623
	ret = ttm_read_lock(&dev_priv->reservation_sem, true);
625
	if (unlikely(ret != 0)) {
624
	if (unlikely(ret != 0)) {
626
		drm_modeset_unlock_all(dev_priv->dev);
625
		drm_modeset_unlock_all(dev_priv->dev);
Line 640... Line 639...
640
 
639
 
641
	ret = do_surface_dirty_sou(dev_priv, file_priv, &vfbs->base,
640
	ret = do_surface_dirty_sou(dev_priv, file_priv, &vfbs->base,
642
				   flags, color,
641
				   flags, color,
Line 643... Line 642...
643
				   clips, num_clips, inc, NULL);
642
				   clips, num_clips, inc, NULL);
Line 644... Line 643...
644
 
643
 
Line 645... Line 644...
645
	ttm_read_unlock(&vmaster->lock);
644
	ttm_read_unlock(&dev_priv->reservation_sem);
646
 
645
 
Line 891... Line 890...
891
		return -ENOMEM;
890
		return -ENOMEM;
892
	}
891
	}
Line 893... Line 892...
893
 
892
 
894
	num_units = 0;
893
	num_units = 0;
895
	list_for_each_entry(crtc, &dev_priv->dev->mode_config.crtc_list, head) {
894
	list_for_each_entry(crtc, &dev_priv->dev->mode_config.crtc_list, head) {
896
		if (crtc->fb != &framebuffer->base)
895
		if (crtc->primary->fb != &framebuffer->base)
897
			continue;
896
			continue;
898
		units[num_units++] = vmw_crtc_to_du(crtc);
897
		units[num_units++] = vmw_crtc_to_du(crtc);
Line 899... Line 898...
899
	}
898
	}
Line 962... Line 961...
962
				 unsigned flags, unsigned color,
961
				 unsigned flags, unsigned color,
963
				 struct drm_clip_rect *clips,
962
				 struct drm_clip_rect *clips,
964
				 unsigned num_clips)
963
				 unsigned num_clips)
965
{
964
{
966
	struct vmw_private *dev_priv = vmw_priv(framebuffer->dev);
965
	struct vmw_private *dev_priv = vmw_priv(framebuffer->dev);
967
	struct vmw_master *vmaster = vmw_master(file_priv->master);
-
 
968
	struct vmw_framebuffer_dmabuf *vfbd =
966
	struct vmw_framebuffer_dmabuf *vfbd =
969
		vmw_framebuffer_to_vfbd(framebuffer);
967
		vmw_framebuffer_to_vfbd(framebuffer);
970
	struct drm_clip_rect norect;
968
	struct drm_clip_rect norect;
971
	int ret, increment = 1;
969
	int ret, increment = 1;
Line 972... Line 970...
972
 
970
 
Line 973... Line 971...
973
	drm_modeset_lock_all(dev_priv->dev);
971
	drm_modeset_lock_all(dev_priv->dev);
974
 
972
 
975
	ret = ttm_read_lock(&vmaster->lock, true);
973
	ret = ttm_read_lock(&dev_priv->reservation_sem, true);
976
	if (unlikely(ret != 0)) {
974
	if (unlikely(ret != 0)) {
977
		drm_modeset_unlock_all(dev_priv->dev);
975
		drm_modeset_unlock_all(dev_priv->dev);
Line 997... Line 995...
997
		ret = do_dmabuf_dirty_sou(file_priv, dev_priv, &vfbd->base,
995
		ret = do_dmabuf_dirty_sou(file_priv, dev_priv, &vfbd->base,
998
					  flags, color,
996
					  flags, color,
999
					  clips, num_clips, increment, NULL);
997
					  clips, num_clips, increment, NULL);
1000
	}
998
	}
Line 1001... Line 999...
1001
 
999
 
Line 1002... Line 1000...
1002
	ttm_read_unlock(&vmaster->lock);
1000
	ttm_read_unlock(&dev_priv->reservation_sem);
Line 1003... Line 1001...
1003
 
1001
 
1004
	drm_modeset_unlock_all(dev_priv->dev);
1002
	drm_modeset_unlock_all(dev_priv->dev);
Line 1255... Line 1253...
1255
	} *cmd;
1253
	} *cmd;
1256
	SVGASignedRect *blits;
1254
	SVGASignedRect *blits;
Line 1257... Line 1255...
1257
 
1255
 
1258
	num_units = 0;
1256
	num_units = 0;
1259
	list_for_each_entry(crtc, &dev_priv->dev->mode_config.crtc_list, head) {
1257
	list_for_each_entry(crtc, &dev_priv->dev->mode_config.crtc_list, head) {
1260
		if (crtc->fb != &vfb->base)
1258
		if (crtc->primary->fb != &vfb->base)
1261
			continue;
1259
			continue;
1262
		units[num_units++] = vmw_crtc_to_du(crtc);
1260
		units[num_units++] = vmw_crtc_to_du(crtc);
Line 1263... Line 1261...
1263
	}
1261
	}
Line 1392... Line 1390...
1392
		SVGAFifoCmdBlitScreenToGMRFB body;
1390
		SVGAFifoCmdBlitScreenToGMRFB body;
1393
	} *blits;
1391
	} *blits;
Line 1394... Line 1392...
1394
 
1392
 
1395
	num_units = 0;
1393
	num_units = 0;
1396
	list_for_each_entry(crtc, &dev_priv->dev->mode_config.crtc_list, head) {
1394
	list_for_each_entry(crtc, &dev_priv->dev->mode_config.crtc_list, head) {
1397
		if (crtc->fb != &vfb->base)
1395
		if (crtc->primary->fb != &vfb->base)
1398
			continue;
1396
			continue;
1399
		units[num_units++] = vmw_crtc_to_du(crtc);
1397
		units[num_units++] = vmw_crtc_to_du(crtc);
Line 1400... Line 1398...
1400
	}
1398
	}
Line 1478... Line 1476...
1478
int vmw_kms_init(struct vmw_private *dev_priv)
1476
int vmw_kms_init(struct vmw_private *dev_priv)
1479
{
1477
{
1480
	struct drm_device *dev = dev_priv->dev;
1478
	struct drm_device *dev = dev_priv->dev;
1481
	int ret;
1479
	int ret;
Line 1482... Line -...
1482
 
-
 
1483
    ENTER();
-
 
1484
 
1480
 
1485
	drm_mode_config_init(dev);
1481
	drm_mode_config_init(dev);
1486
	dev->mode_config.funcs = &vmw_kms_funcs;
1482
	dev->mode_config.funcs = &vmw_kms_funcs;
1487
	dev->mode_config.min_width = 1;
1483
	dev->mode_config.min_width = 1;
1488
	dev->mode_config.min_height = 1;
1484
	dev->mode_config.min_height = 1;
1489
	/* assumed largest fb size */
1485
	/* assumed largest fb size */
1490
	dev->mode_config.max_width = 8192;
1486
	dev->mode_config.max_width = 8192;
Line 1491... Line 1487...
1491
	dev->mode_config.max_height = 8192;
1487
	dev->mode_config.max_height = 8192;
1492
 
-
 
1493
	ret = vmw_kms_init_screen_object_display(dev_priv);
-
 
1494
//    if (ret) /* Fallback */
-
 
1495
//       (void)vmw_kms_init_legacy_display_system(dev_priv);
-
 
Line 1496... Line 1488...
1496
 
1488
 
1497
    LEAVE();
1489
	ret = vmw_kms_init_screen_object_display(dev_priv);
Line 1498... Line 1490...
1498
 
1490
 
Line 1518... Line 1510...
1518
int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data,
1510
int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data,
1519
				struct drm_file *file_priv)
1511
				struct drm_file *file_priv)
1520
{
1512
{
1521
	struct drm_vmw_cursor_bypass_arg *arg = data;
1513
	struct drm_vmw_cursor_bypass_arg *arg = data;
1522
	struct vmw_display_unit *du;
1514
	struct vmw_display_unit *du;
1523
	struct drm_mode_object *obj;
-
 
1524
	struct drm_crtc *crtc;
1515
	struct drm_crtc *crtc;
1525
	int ret = 0;
1516
	int ret = 0;
Line 1526... Line 1517...
1526
 
1517
 
Line 1536... Line 1527...
1536
 
1527
 
1537
		mutex_unlock(&dev->mode_config.mutex);
1528
		mutex_unlock(&dev->mode_config.mutex);
1538
		return 0;
1529
		return 0;
Line 1539... Line 1530...
1539
	}
1530
	}
1540
 
1531
 
1541
	obj = drm_mode_object_find(dev, arg->crtc_id, DRM_MODE_OBJECT_CRTC);
1532
	crtc = drm_crtc_find(dev, arg->crtc_id);
1542
	if (!obj) {
1533
	if (!crtc) {
1543
		ret = -ENOENT;
1534
		ret = -ENOENT;
Line 1544... Line -...
1544
		goto out;
-
 
1545
	}
1535
		goto out;
Line 1546... Line 1536...
1546
 
1536
	}
1547
	crtc = obj_to_crtc(obj);
1537
 
Line 1742... Line 1732...
1742
		     struct drm_framebuffer *fb,
1732
		     struct drm_framebuffer *fb,
1743
		     struct drm_pending_vblank_event *event,
1733
		     struct drm_pending_vblank_event *event,
1744
		     uint32_t page_flip_flags)
1734
		     uint32_t page_flip_flags)
1745
{
1735
{
1746
	struct vmw_private *dev_priv = vmw_priv(crtc->dev);
1736
	struct vmw_private *dev_priv = vmw_priv(crtc->dev);
1747
	struct drm_framebuffer *old_fb = crtc->fb;
1737
	struct drm_framebuffer *old_fb = crtc->primary->fb;
1748
	struct vmw_framebuffer *vfb = vmw_framebuffer_to_vfb(fb);
1738
	struct vmw_framebuffer *vfb = vmw_framebuffer_to_vfb(fb);
1749
	struct drm_file *file_priv ;
1739
	struct drm_file *file_priv ;
1750
	struct vmw_fence_obj *fence = NULL;
1740
	struct vmw_fence_obj *fence = NULL;
1751
	struct drm_clip_rect clips;
1741
	struct drm_clip_rect clips;
1752
	int ret;
1742
	int ret;
Line 1760... Line 1750...
1760
 
1750
 
1761
	file_priv = event->base.file_priv;
1751
	file_priv = event->base.file_priv;
1762
	if (!vmw_kms_screen_object_flippable(dev_priv, crtc))
1752
	if (!vmw_kms_screen_object_flippable(dev_priv, crtc))
Line 1763... Line 1753...
1763
		return -EINVAL;
1753
		return -EINVAL;
Line 1764... Line 1754...
1764
 
1754
 
1765
	crtc->fb = fb;
1755
	crtc->primary->fb = fb;
1766
 
1756
 
1767
	/* do a full screen dirty update */
1757
	/* do a full screen dirty update */
Line 1800... Line 1790...
1800
		vmw_kms_screen_object_update_implicit_fb(dev_priv, crtc);
1790
		vmw_kms_screen_object_update_implicit_fb(dev_priv, crtc);
Line 1801... Line 1791...
1801
 
1791
 
Line 1802... Line 1792...
1802
	return ret;
1792
	return ret;
1803
 
1793
 
1804
out_no_fence:
1794
out_no_fence:
1805
	crtc->fb = old_fb;
1795
	crtc->primary->fb = old_fb;
1806
	return ret;
1796
	return ret;
Line 1807... Line 1797...
1807
}
1797
}
Line 2024... Line 2014...
2024
 
2014
 
2025
	/* Move the prefered mode first, help apps pick the right mode. */
2015
	/* Move the prefered mode first, help apps pick the right mode. */
2026
	if (du->pref_mode)
2016
	if (du->pref_mode)
Line 2027... Line 2017...
2027
		list_move(&du->pref_mode->head, &connector->probed_modes);
2017
		list_move(&du->pref_mode->head, &connector->probed_modes);
Line 2028... Line 2018...
2028
 
2018
 
2029
	drm_mode_connector_list_update(connector);
2019
	drm_mode_connector_list_update(connector, true);
Line 2030... Line 2020...
2030
 
2020
 
Line 2043... Line 2033...
2043
				struct drm_file *file_priv)
2033
				struct drm_file *file_priv)
2044
{
2034
{
2045
	struct vmw_private *dev_priv = vmw_priv(dev);
2035
	struct vmw_private *dev_priv = vmw_priv(dev);
2046
	struct drm_vmw_update_layout_arg *arg =
2036
	struct drm_vmw_update_layout_arg *arg =
2047
		(struct drm_vmw_update_layout_arg *)data;
2037
		(struct drm_vmw_update_layout_arg *)data;
2048
	struct vmw_master *vmaster = vmw_master(file_priv->master);
-
 
2049
	void __user *user_rects;
2038
	void __user *user_rects;
2050
	struct drm_vmw_rect *rects;
2039
	struct drm_vmw_rect *rects;
2051
	unsigned rects_size;
2040
	unsigned rects_size;
2052
	int ret;
2041
	int ret;
2053
	int i;
2042
	int i;
2054
	struct drm_mode_config *mode_config = &dev->mode_config;
2043
	struct drm_mode_config *mode_config = &dev->mode_config;
Line 2055... Line 2044...
2055
 
2044
 
2056
	ret = ttm_read_lock(&vmaster->lock, true);
2045
	ret = ttm_read_lock(&dev_priv->reservation_sem, true);
2057
	if (unlikely(ret != 0))
2046
	if (unlikely(ret != 0))
Line 2058... Line 2047...
2058
		return ret;
2047
		return ret;
2059
 
2048
 
Line 2093... Line 2082...
2093
	vmw_du_update_layout(dev_priv, arg->num_outputs, rects);
2082
	vmw_du_update_layout(dev_priv, arg->num_outputs, rects);
Line 2094... Line 2083...
2094
 
2083
 
2095
out_free:
2084
out_free:
2096
	kfree(rects);
2085
	kfree(rects);
2097
out_unlock:
2086
out_unlock:
2098
	ttm_read_unlock(&vmaster->lock);
2087
	ttm_read_unlock(&dev_priv->reservation_sem);
2099
	return ret;
2088
	return ret;
2100
}
2089
}