drm.c (6ea24cf79e055f0a62a64baa8587e2254a493c7b) | drm.c (33a8eb8d40ee7fc07f23a407607bdbaa46893b2d) |
---|---|
1/* 2 * Copyright (C) 2012 Avionic Design GmbH 3 * Copyright (C) 2012-2013 NVIDIA CORPORATION. All rights reserved. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License version 2 as 7 * published by the Free Software Foundation. 8 */ --- 42 unchanged lines hidden (view full) --- 51 * This scheme allows new atomic state updates to be prepared and 52 * checked in parallel to the asynchronous completion of the previous 53 * update. Which is important since compositors need to figure out the 54 * composition of the next frame right after having submitted the 55 * current layout. 56 */ 57 58 drm_atomic_helper_commit_modeset_disables(drm, state); | 1/* 2 * Copyright (C) 2012 Avionic Design GmbH 3 * Copyright (C) 2012-2013 NVIDIA CORPORATION. All rights reserved. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License version 2 as 7 * published by the Free Software Foundation. 8 */ --- 42 unchanged lines hidden (view full) --- 51 * This scheme allows new atomic state updates to be prepared and 52 * checked in parallel to the asynchronous completion of the previous 53 * update. Which is important since compositors need to figure out the 54 * composition of the next frame right after having submitted the 55 * current layout. 56 */ 57 58 drm_atomic_helper_commit_modeset_disables(drm, state); |
59 drm_atomic_helper_commit_planes(drm, state, false); | |
60 drm_atomic_helper_commit_modeset_enables(drm, state); | 59 drm_atomic_helper_commit_modeset_enables(drm, state); |
60 drm_atomic_helper_commit_planes(drm, state, true); |
|
61 62 drm_atomic_helper_wait_for_vblanks(drm, state); 63 64 drm_atomic_helper_cleanup_planes(drm, state); 65 drm_atomic_state_free(state); 66} 67 68static void tegra_atomic_work(struct work_struct *work) 69{ 70 struct tegra_drm *tegra = container_of(work, struct tegra_drm, 71 commit.work); 72 73 tegra_atomic_complete(tegra, tegra->commit.state); 74} 75 76static int tegra_atomic_commit(struct drm_device *drm, | 61 62 drm_atomic_helper_wait_for_vblanks(drm, state); 63 64 drm_atomic_helper_cleanup_planes(drm, state); 65 drm_atomic_state_free(state); 66} 67 68static void tegra_atomic_work(struct work_struct *work) 69{ 70 struct tegra_drm *tegra = container_of(work, struct tegra_drm, 71 commit.work); 72 73 tegra_atomic_complete(tegra, tegra->commit.state); 74} 75 76static int tegra_atomic_commit(struct drm_device *drm, |
77 struct drm_atomic_state *state, bool async) | 77 struct drm_atomic_state *state, bool nonblock) |
78{ 79 struct tegra_drm *tegra = drm->dev_private; 80 int err; 81 82 err = drm_atomic_helper_prepare_planes(drm, state); 83 if (err) 84 return err; 85 | 78{ 79 struct tegra_drm *tegra = drm->dev_private; 80 int err; 81 82 err = drm_atomic_helper_prepare_planes(drm, state); 83 if (err) 84 return err; 85 |
86 /* serialize outstanding asynchronous commits */ | 86 /* serialize outstanding nonblocking commits */ |
87 mutex_lock(&tegra->commit.lock); 88 flush_work(&tegra->commit.work); 89 90 /* 91 * This is the point of no return - everything below never fails except 92 * when the hw goes bonghits. Which means we can commit the new state on 93 * the software side now. 94 */ 95 96 drm_atomic_helper_swap_state(drm, state); 97 | 87 mutex_lock(&tegra->commit.lock); 88 flush_work(&tegra->commit.work); 89 90 /* 91 * This is the point of no return - everything below never fails except 92 * when the hw goes bonghits. Which means we can commit the new state on 93 * the software side now. 94 */ 95 96 drm_atomic_helper_swap_state(drm, state); 97 |
98 if (async) | 98 if (nonblock) |
99 tegra_atomic_schedule(tegra, state); 100 else 101 tegra_atomic_complete(tegra, state); 102 103 mutex_unlock(&tegra->commit.lock); 104 return 0; 105} 106 --- 68 unchanged lines hidden (view full) --- 175 * We don't use the drm_irq_install() helpers provided by the DRM 176 * core, so we need to set this manually in order to allow the 177 * DRM_IOCTL_WAIT_VBLANK to operate correctly. 178 */ 179 drm->irq_enabled = true; 180 181 /* syncpoints are used for full 32-bit hardware VBLANK counters */ 182 drm->max_vblank_count = 0xffffffff; | 99 tegra_atomic_schedule(tegra, state); 100 else 101 tegra_atomic_complete(tegra, state); 102 103 mutex_unlock(&tegra->commit.lock); 104 return 0; 105} 106 --- 68 unchanged lines hidden (view full) --- 175 * We don't use the drm_irq_install() helpers provided by the DRM 176 * core, so we need to set this manually in order to allow the 177 * DRM_IOCTL_WAIT_VBLANK to operate correctly. 178 */ 179 drm->irq_enabled = true; 180 181 /* syncpoints are used for full 32-bit hardware VBLANK counters */ 182 drm->max_vblank_count = 0xffffffff; |
183 drm->vblank_disable_allowed = true; | |
184 185 err = drm_vblank_init(drm, drm->mode_config.num_crtc); 186 if (err < 0) 187 goto device; 188 189 drm_mode_config_reset(drm); 190 191 err = tegra_drm_fb_init(drm); --- 71 unchanged lines hidden (view full) --- 263#ifdef CONFIG_DRM_FBDEV_EMULATION 264 struct tegra_drm *tegra = drm->dev_private; 265 266 tegra_fbdev_restore_mode(tegra->fbdev); 267#endif 268} 269 270static struct host1x_bo * | 183 184 err = drm_vblank_init(drm, drm->mode_config.num_crtc); 185 if (err < 0) 186 goto device; 187 188 drm_mode_config_reset(drm); 189 190 err = tegra_drm_fb_init(drm); --- 71 unchanged lines hidden (view full) --- 262#ifdef CONFIG_DRM_FBDEV_EMULATION 263 struct tegra_drm *tegra = drm->dev_private; 264 265 tegra_fbdev_restore_mode(tegra->fbdev); 266#endif 267} 268 269static struct host1x_bo * |
271host1x_bo_lookup(struct drm_device *drm, struct drm_file *file, u32 handle) | 270host1x_bo_lookup(struct drm_file *file, u32 handle) |
272{ 273 struct drm_gem_object *gem; 274 struct tegra_bo *bo; 275 | 271{ 272 struct drm_gem_object *gem; 273 struct tegra_bo *bo; 274 |
276 gem = drm_gem_object_lookup(drm, file, handle); | 275 gem = drm_gem_object_lookup(file, handle); |
277 if (!gem) 278 return NULL; 279 280 drm_gem_object_unreference_unlocked(gem); 281 282 bo = to_tegra_bo(gem); 283 return &bo->base; 284} --- 21 unchanged lines hidden (view full) --- 306 err = get_user(dest->target.offset, &src->target.offset); 307 if (err < 0) 308 return err; 309 310 err = get_user(dest->shift, &src->shift); 311 if (err < 0) 312 return err; 313 | 276 if (!gem) 277 return NULL; 278 279 drm_gem_object_unreference_unlocked(gem); 280 281 bo = to_tegra_bo(gem); 282 return &bo->base; 283} --- 21 unchanged lines hidden (view full) --- 305 err = get_user(dest->target.offset, &src->target.offset); 306 if (err < 0) 307 return err; 308 309 err = get_user(dest->shift, &src->shift); 310 if (err < 0) 311 return err; 312 |
314 dest->cmdbuf.bo = host1x_bo_lookup(drm, file, cmdbuf); | 313 dest->cmdbuf.bo = host1x_bo_lookup(file, cmdbuf); |
315 if (!dest->cmdbuf.bo) 316 return -ENOENT; 317 | 314 if (!dest->cmdbuf.bo) 315 return -ENOENT; 316 |
318 dest->target.bo = host1x_bo_lookup(drm, file, target); | 317 dest->target.bo = host1x_bo_lookup(file, target); |
319 if (!dest->target.bo) 320 return -ENOENT; 321 322 return 0; 323} 324 325int tegra_drm_submit(struct tegra_drm_context *context, 326 struct drm_tegra_submit *args, struct drm_device *drm, --- 31 unchanged lines hidden (view full) --- 358 struct drm_tegra_cmdbuf cmdbuf; 359 struct host1x_bo *bo; 360 361 if (copy_from_user(&cmdbuf, cmdbufs, sizeof(cmdbuf))) { 362 err = -EFAULT; 363 goto fail; 364 } 365 | 318 if (!dest->target.bo) 319 return -ENOENT; 320 321 return 0; 322} 323 324int tegra_drm_submit(struct tegra_drm_context *context, 325 struct drm_tegra_submit *args, struct drm_device *drm, --- 31 unchanged lines hidden (view full) --- 357 struct drm_tegra_cmdbuf cmdbuf; 358 struct host1x_bo *bo; 359 360 if (copy_from_user(&cmdbuf, cmdbufs, sizeof(cmdbuf))) { 361 err = -EFAULT; 362 goto fail; 363 } 364 |
366 bo = host1x_bo_lookup(drm, file, cmdbuf.handle); | 365 bo = host1x_bo_lookup(file, cmdbuf.handle); |
367 if (!bo) { 368 err = -ENOENT; 369 goto fail; 370 } 371 372 host1x_job_add_gather(job, bo, cmdbuf.words, cmdbuf.offset); 373 num_cmdbufs--; 374 cmdbufs++; --- 83 unchanged lines hidden (view full) --- 458 459static int tegra_gem_mmap(struct drm_device *drm, void *data, 460 struct drm_file *file) 461{ 462 struct drm_tegra_gem_mmap *args = data; 463 struct drm_gem_object *gem; 464 struct tegra_bo *bo; 465 | 366 if (!bo) { 367 err = -ENOENT; 368 goto fail; 369 } 370 371 host1x_job_add_gather(job, bo, cmdbuf.words, cmdbuf.offset); 372 num_cmdbufs--; 373 cmdbufs++; --- 83 unchanged lines hidden (view full) --- 457 458static int tegra_gem_mmap(struct drm_device *drm, void *data, 459 struct drm_file *file) 460{ 461 struct drm_tegra_gem_mmap *args = data; 462 struct drm_gem_object *gem; 463 struct tegra_bo *bo; 464 |
466 gem = drm_gem_object_lookup(drm, file, args->handle); | 465 gem = drm_gem_object_lookup(file, args->handle); |
467 if (!gem) 468 return -EINVAL; 469 470 bo = to_tegra_bo(gem); 471 472 args->offset = drm_vma_node_offset_addr(&bo->gem.vma_node); 473 474 drm_gem_object_unreference_unlocked(gem); --- 192 unchanged lines hidden (view full) --- 667 668 value = args->value; 669 break; 670 671 default: 672 return -EINVAL; 673 } 674 | 466 if (!gem) 467 return -EINVAL; 468 469 bo = to_tegra_bo(gem); 470 471 args->offset = drm_vma_node_offset_addr(&bo->gem.vma_node); 472 473 drm_gem_object_unreference_unlocked(gem); --- 192 unchanged lines hidden (view full) --- 666 667 value = args->value; 668 break; 669 670 default: 671 return -EINVAL; 672 } 673 |
675 gem = drm_gem_object_lookup(drm, file, args->handle); | 674 gem = drm_gem_object_lookup(file, args->handle); |
676 if (!gem) 677 return -ENOENT; 678 679 bo = to_tegra_bo(gem); 680 681 bo->tiling.mode = mode; 682 bo->tiling.value = value; 683 --- 5 unchanged lines hidden (view full) --- 689static int tegra_gem_get_tiling(struct drm_device *drm, void *data, 690 struct drm_file *file) 691{ 692 struct drm_tegra_gem_get_tiling *args = data; 693 struct drm_gem_object *gem; 694 struct tegra_bo *bo; 695 int err = 0; 696 | 675 if (!gem) 676 return -ENOENT; 677 678 bo = to_tegra_bo(gem); 679 680 bo->tiling.mode = mode; 681 bo->tiling.value = value; 682 --- 5 unchanged lines hidden (view full) --- 688static int tegra_gem_get_tiling(struct drm_device *drm, void *data, 689 struct drm_file *file) 690{ 691 struct drm_tegra_gem_get_tiling *args = data; 692 struct drm_gem_object *gem; 693 struct tegra_bo *bo; 694 int err = 0; 695 |
697 gem = drm_gem_object_lookup(drm, file, args->handle); | 696 gem = drm_gem_object_lookup(file, args->handle); |
698 if (!gem) 699 return -ENOENT; 700 701 bo = to_tegra_bo(gem); 702 703 switch (bo->tiling.mode) { 704 case TEGRA_BO_TILING_MODE_PITCH: 705 args->mode = DRM_TEGRA_GEM_TILING_MODE_PITCH; --- 25 unchanged lines hidden (view full) --- 731{ 732 struct drm_tegra_gem_set_flags *args = data; 733 struct drm_gem_object *gem; 734 struct tegra_bo *bo; 735 736 if (args->flags & ~DRM_TEGRA_GEM_FLAGS) 737 return -EINVAL; 738 | 697 if (!gem) 698 return -ENOENT; 699 700 bo = to_tegra_bo(gem); 701 702 switch (bo->tiling.mode) { 703 case TEGRA_BO_TILING_MODE_PITCH: 704 args->mode = DRM_TEGRA_GEM_TILING_MODE_PITCH; --- 25 unchanged lines hidden (view full) --- 730{ 731 struct drm_tegra_gem_set_flags *args = data; 732 struct drm_gem_object *gem; 733 struct tegra_bo *bo; 734 735 if (args->flags & ~DRM_TEGRA_GEM_FLAGS) 736 return -EINVAL; 737 |
739 gem = drm_gem_object_lookup(drm, file, args->handle); | 738 gem = drm_gem_object_lookup(file, args->handle); |
740 if (!gem) 741 return -ENOENT; 742 743 bo = to_tegra_bo(gem); 744 bo->flags = 0; 745 746 if (args->flags & DRM_TEGRA_GEM_BOTTOM_UP) 747 bo->flags |= TEGRA_BO_BOTTOM_UP; --- 5 unchanged lines hidden (view full) --- 753 754static int tegra_gem_get_flags(struct drm_device *drm, void *data, 755 struct drm_file *file) 756{ 757 struct drm_tegra_gem_get_flags *args = data; 758 struct drm_gem_object *gem; 759 struct tegra_bo *bo; 760 | 739 if (!gem) 740 return -ENOENT; 741 742 bo = to_tegra_bo(gem); 743 bo->flags = 0; 744 745 if (args->flags & DRM_TEGRA_GEM_BOTTOM_UP) 746 bo->flags |= TEGRA_BO_BOTTOM_UP; --- 5 unchanged lines hidden (view full) --- 752 753static int tegra_gem_get_flags(struct drm_device *drm, void *data, 754 struct drm_file *file) 755{ 756 struct drm_tegra_gem_get_flags *args = data; 757 struct drm_gem_object *gem; 758 struct tegra_bo *bo; 759 |
761 gem = drm_gem_object_lookup(drm, file, args->handle); | 760 gem = drm_gem_object_lookup(file, args->handle); |
762 if (!gem) 763 return -ENOENT; 764 765 bo = to_tegra_bo(gem); 766 args->flags = 0; 767 768 if (bo->flags & TEGRA_BO_BOTTOM_UP) 769 args->flags |= DRM_TEGRA_GEM_BOTTOM_UP; --- 103 unchanged lines hidden (view full) --- 873 struct drm_framebuffer *fb; 874 875 mutex_lock(&drm->mode_config.fb_lock); 876 877 list_for_each_entry(fb, &drm->mode_config.fb_list, head) { 878 seq_printf(s, "%3d: user size: %d x %d, depth %d, %d bpp, refcount %d\n", 879 fb->base.id, fb->width, fb->height, fb->depth, 880 fb->bits_per_pixel, | 761 if (!gem) 762 return -ENOENT; 763 764 bo = to_tegra_bo(gem); 765 args->flags = 0; 766 767 if (bo->flags & TEGRA_BO_BOTTOM_UP) 768 args->flags |= DRM_TEGRA_GEM_BOTTOM_UP; --- 103 unchanged lines hidden (view full) --- 872 struct drm_framebuffer *fb; 873 874 mutex_lock(&drm->mode_config.fb_lock); 875 876 list_for_each_entry(fb, &drm->mode_config.fb_list, head) { 877 seq_printf(s, "%3d: user size: %d x %d, depth %d, %d bpp, refcount %d\n", 878 fb->base.id, fb->width, fb->height, fb->depth, 879 fb->bits_per_pixel, |
881 atomic_read(&fb->refcount.refcount)); | 880 drm_framebuffer_read_refcount(fb)); |
882 } 883 884 mutex_unlock(&drm->mode_config.fb_lock); 885 886 return 0; 887} 888 889static int tegra_debugfs_iova(struct seq_file *s, void *data) --- 37 unchanged lines hidden (view full) --- 927 .enable_vblank = tegra_drm_enable_vblank, 928 .disable_vblank = tegra_drm_disable_vblank, 929 930#if defined(CONFIG_DEBUG_FS) 931 .debugfs_init = tegra_debugfs_init, 932 .debugfs_cleanup = tegra_debugfs_cleanup, 933#endif 934 | 881 } 882 883 mutex_unlock(&drm->mode_config.fb_lock); 884 885 return 0; 886} 887 888static int tegra_debugfs_iova(struct seq_file *s, void *data) --- 37 unchanged lines hidden (view full) --- 926 .enable_vblank = tegra_drm_enable_vblank, 927 .disable_vblank = tegra_drm_disable_vblank, 928 929#if defined(CONFIG_DEBUG_FS) 930 .debugfs_init = tegra_debugfs_init, 931 .debugfs_cleanup = tegra_debugfs_cleanup, 932#endif 933 |
935 .gem_free_object = tegra_bo_free_object, | 934 .gem_free_object_unlocked = tegra_bo_free_object, |
936 .gem_vm_ops = &tegra_bo_vm_ops, 937 938 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, 939 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, 940 .gem_prime_export = tegra_gem_prime_export, 941 .gem_prime_import = tegra_gem_prime_import, 942 943 .dumb_create = tegra_bo_dumb_create, --- 181 unchanged lines hidden --- | 935 .gem_vm_ops = &tegra_bo_vm_ops, 936 937 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, 938 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, 939 .gem_prime_export = tegra_gem_prime_export, 940 .gem_prime_import = tegra_gem_prime_import, 941 942 .dumb_create = tegra_bo_dumb_create, --- 181 unchanged lines hidden --- |