| 1 | // SPDX-License-Identifier: MIT |
| 2 | /* Copyright © 2024 Intel Corporation */ |
| 3 | |
| 4 | #include <drm/drm_panic.h> |
| 5 | |
| 6 | #include "gem/i915_gem_mman.h" |
| 7 | #include "gem/i915_gem_object.h" |
| 8 | #include "gem/i915_gem_object_frontbuffer.h" |
| 9 | #include "i915_debugfs.h" |
| 10 | #include "intel_bo.h" |
| 11 | |
| 12 | bool intel_bo_is_tiled(struct drm_gem_object *obj) |
| 13 | { |
| 14 | return i915_gem_object_is_tiled(obj: to_intel_bo(gem: obj)); |
| 15 | } |
| 16 | |
| 17 | bool intel_bo_is_userptr(struct drm_gem_object *obj) |
| 18 | { |
| 19 | return i915_gem_object_is_userptr(obj: to_intel_bo(gem: obj)); |
| 20 | } |
| 21 | |
| 22 | bool intel_bo_is_shmem(struct drm_gem_object *obj) |
| 23 | { |
| 24 | return i915_gem_object_is_shmem(obj: to_intel_bo(gem: obj)); |
| 25 | } |
| 26 | |
| 27 | bool intel_bo_is_protected(struct drm_gem_object *obj) |
| 28 | { |
| 29 | return i915_gem_object_is_protected(obj: to_intel_bo(gem: obj)); |
| 30 | } |
| 31 | |
| 32 | int intel_bo_fb_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) |
| 33 | { |
| 34 | return i915_gem_fb_mmap(obj: to_intel_bo(gem: obj), vma); |
| 35 | } |
| 36 | |
| 37 | int intel_bo_read_from_page(struct drm_gem_object *obj, u64 offset, void *dst, int size) |
| 38 | { |
| 39 | return i915_gem_object_read_from_page(obj: to_intel_bo(gem: obj), offset, dst, size); |
| 40 | } |
| 41 | |
| 42 | struct intel_frontbuffer *intel_bo_frontbuffer_get(struct drm_gem_object *_obj) |
| 43 | { |
| 44 | struct drm_i915_gem_object *obj = to_intel_bo(gem: _obj); |
| 45 | struct i915_frontbuffer *front; |
| 46 | |
| 47 | front = i915_gem_object_frontbuffer_get(obj); |
| 48 | if (!front) |
| 49 | return NULL; |
| 50 | |
| 51 | return &front->base; |
| 52 | } |
| 53 | |
| 54 | void intel_bo_frontbuffer_ref(struct intel_frontbuffer *_front) |
| 55 | { |
| 56 | struct i915_frontbuffer *front = |
| 57 | container_of(_front, typeof(*front), base); |
| 58 | |
| 59 | i915_gem_object_frontbuffer_ref(front); |
| 60 | } |
| 61 | |
| 62 | void intel_bo_frontbuffer_put(struct intel_frontbuffer *_front) |
| 63 | { |
| 64 | struct i915_frontbuffer *front = |
| 65 | container_of(_front, typeof(*front), base); |
| 66 | |
| 67 | return i915_gem_object_frontbuffer_put(front); |
| 68 | } |
| 69 | |
| 70 | void intel_bo_frontbuffer_flush_for_display(struct intel_frontbuffer *_front) |
| 71 | { |
| 72 | struct i915_frontbuffer *front = |
| 73 | container_of(_front, typeof(*front), base); |
| 74 | |
| 75 | i915_gem_object_flush_if_display(obj: front->obj); |
| 76 | } |
| 77 | |
| 78 | void intel_bo_describe(struct seq_file *m, struct drm_gem_object *obj) |
| 79 | { |
| 80 | i915_debugfs_describe_obj(m, obj: to_intel_bo(gem: obj)); |
| 81 | } |
| 82 | |