| 1 | // SPDX-License-Identifier: MIT |
| 2 | /* Copyright © 2024 Intel Corporation */ |
| 3 | |
| 4 | #include <drm/drm_gem.h> |
| 5 | |
| 6 | #include "xe_bo.h" |
| 7 | #include "intel_bo.h" |
| 8 | #include "intel_frontbuffer.h" |
| 9 | |
| 10 | bool intel_bo_is_tiled(struct drm_gem_object *obj) |
| 11 | { |
| 12 | /* legacy tiling is unused */ |
| 13 | return false; |
| 14 | } |
| 15 | |
| 16 | bool intel_bo_is_userptr(struct drm_gem_object *obj) |
| 17 | { |
| 18 | /* xe does not have userptr bos */ |
| 19 | return false; |
| 20 | } |
| 21 | |
| 22 | bool intel_bo_is_shmem(struct drm_gem_object *obj) |
| 23 | { |
| 24 | return false; |
| 25 | } |
| 26 | |
| 27 | bool intel_bo_is_protected(struct drm_gem_object *obj) |
| 28 | { |
| 29 | return xe_bo_is_protected(gem_to_xe_bo(obj)); |
| 30 | } |
| 31 | |
| 32 | int intel_bo_fb_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) |
| 33 | { |
| 34 | return drm_gem_prime_mmap(obj, vma); |
| 35 | } |
| 36 | |
| 37 | int intel_bo_read_from_page(struct drm_gem_object *obj, u64 offset, void *dst, int size) |
| 38 | { |
| 39 | struct xe_bo *bo = gem_to_xe_bo(obj); |
| 40 | |
| 41 | return xe_bo_read(bo, offset, dst, size); |
| 42 | } |
| 43 | |
| 44 | struct xe_frontbuffer { |
| 45 | struct intel_frontbuffer base; |
| 46 | struct drm_gem_object *obj; |
| 47 | struct kref ref; |
| 48 | }; |
| 49 | |
| 50 | struct intel_frontbuffer *intel_bo_frontbuffer_get(struct drm_gem_object *obj) |
| 51 | { |
| 52 | struct xe_frontbuffer *front; |
| 53 | |
| 54 | front = kmalloc(sizeof(*front), GFP_KERNEL); |
| 55 | if (!front) |
| 56 | return NULL; |
| 57 | |
| 58 | intel_frontbuffer_init(&front->base, obj->dev); |
| 59 | |
| 60 | kref_init(kref: &front->ref); |
| 61 | |
| 62 | drm_gem_object_get(obj); |
| 63 | front->obj = obj; |
| 64 | |
| 65 | return &front->base; |
| 66 | } |
| 67 | |
| 68 | void intel_bo_frontbuffer_ref(struct intel_frontbuffer *_front) |
| 69 | { |
| 70 | struct xe_frontbuffer *front = |
| 71 | container_of(_front, typeof(*front), base); |
| 72 | |
| 73 | kref_get(kref: &front->ref); |
| 74 | } |
| 75 | |
| 76 | static void frontbuffer_release(struct kref *ref) |
| 77 | { |
| 78 | struct xe_frontbuffer *front = |
| 79 | container_of(ref, typeof(*front), ref); |
| 80 | |
| 81 | intel_frontbuffer_fini(&front->base); |
| 82 | |
| 83 | drm_gem_object_put(obj: front->obj); |
| 84 | |
| 85 | kfree(objp: front); |
| 86 | } |
| 87 | |
| 88 | void intel_bo_frontbuffer_put(struct intel_frontbuffer *_front) |
| 89 | { |
| 90 | struct xe_frontbuffer *front = |
| 91 | container_of(_front, typeof(*front), base); |
| 92 | |
| 93 | kref_put(kref: &front->ref, release: frontbuffer_release); |
| 94 | } |
| 95 | |
| 96 | void intel_bo_frontbuffer_flush_for_display(struct intel_frontbuffer *front) |
| 97 | { |
| 98 | } |
| 99 | |
| 100 | void intel_bo_describe(struct seq_file *m, struct drm_gem_object *obj) |
| 101 | { |
| 102 | /* FIXME */ |
| 103 | } |
| 104 | |