unsigned long
i915_gem_obj_ggtt_offset_view(struct drm_i915_gem_object *o,
- enum i915_ggtt_view_type view);
+ const struct i915_ggtt_view *view);
unsigned long
i915_gem_obj_offset(struct drm_i915_gem_object *o,
struct i915_address_space *vm);
static inline unsigned long
i915_gem_obj_ggtt_offset(struct drm_i915_gem_object *o)
{
- return i915_gem_obj_ggtt_offset_view(o, I915_GGTT_VIEW_NORMAL);
+ return i915_gem_obj_ggtt_offset_view(o, &i915_ggtt_view_normal);
}
bool i915_gem_obj_bound_any(struct drm_i915_gem_object *o);
bool i915_gem_obj_ggtt_bound_view(struct drm_i915_gem_object *o,
- enum i915_ggtt_view_type view);
+ const struct i915_ggtt_view *view);
bool i915_gem_obj_bound(struct drm_i915_gem_object *o,
struct i915_address_space *vm);
static inline bool i915_gem_obj_ggtt_bound(struct drm_i915_gem_object *obj)
{
- return i915_gem_obj_ggtt_bound_view(obj, I915_GGTT_VIEW_NORMAL);
+ return i915_gem_obj_ggtt_bound_view(obj, &i915_ggtt_view_normal);
}
static inline unsigned long
if (i915_vma_misplaced(vma, alignment, flags)) {
unsigned long offset;
- offset = ggtt_view ? i915_gem_obj_ggtt_offset_view(obj, ggtt_view->type) :
+ offset = ggtt_view ? i915_gem_obj_ggtt_offset_view(obj, ggtt_view) :
i915_gem_obj_offset(obj, vm);
WARN(vma->pin_count,
"bo is already pinned in %s with incorrect alignment:"
BUG_ON(!vma);
WARN_ON(vma->pin_count == 0);
- WARN_ON(!i915_gem_obj_ggtt_bound_view(obj, view->type));
+ WARN_ON(!i915_gem_obj_ggtt_bound_view(obj, view));
if (--vma->pin_count == 0 && view->type == I915_GGTT_VIEW_NORMAL)
obj->pin_mappable = false;
return ERR_PTR(-EINVAL);
list_for_each_entry(vma, &obj->vma_list, vma_link)
- if (vma->vm == ggtt && vma->ggtt_view.type == view->type)
+ if (vma->vm == ggtt &&
+ i915_ggtt_view_equal(&vma->ggtt_view, view))
return vma;
return NULL;
}
unsigned long
i915_gem_obj_ggtt_offset_view(struct drm_i915_gem_object *o,
- enum i915_ggtt_view_type view)
+ const struct i915_ggtt_view *view)
{
struct i915_address_space *ggtt = i915_obj_to_ggtt(o);
struct i915_vma *vma;
list_for_each_entry(vma, &o->vma_list, vma_link)
- if (vma->vm == ggtt && vma->ggtt_view.type == view)
+ if (vma->vm == ggtt &&
+ i915_ggtt_view_equal(&vma->ggtt_view, view))
return vma->node.start;
WARN(1, "global vma for this object not found.\n");
}
bool i915_gem_obj_ggtt_bound_view(struct drm_i915_gem_object *o,
- enum i915_ggtt_view_type view)
+ const struct i915_ggtt_view *view)
{
struct i915_address_space *ggtt = i915_obj_to_ggtt(o);
struct i915_vma *vma;
list_for_each_entry(vma, &o->vma_list, vma_link)
if (vma->vm == ggtt &&
- vma->ggtt_view.type == view &&
+ i915_ggtt_view_equal(&vma->ggtt_view, view) &&
drm_mm_node_allocated(&vma->node))
return true;
*/
const struct i915_ggtt_view i915_ggtt_view_normal;
+const struct i915_ggtt_view i915_ggtt_view_rotated = {
+ .type = I915_GGTT_VIEW_ROTATED
+};
static void bdw_setup_private_ppat(struct drm_i915_private *dev_priv);
static void chv_setup_private_ppat(struct drm_i915_private *dev_priv);
};
extern const struct i915_ggtt_view i915_ggtt_view_normal;
+extern const struct i915_ggtt_view i915_ggtt_view_rotated;
enum i915_cache_level;
int __must_check i915_gem_gtt_prepare_object(struct drm_i915_gem_object *obj);
void i915_gem_gtt_finish_object(struct drm_i915_gem_object *obj);
+static inline bool
+i915_ggtt_view_equal(const struct i915_ggtt_view *a,
+ const struct i915_ggtt_view *b)
+{
+ if (WARN_ON(!a || !b))
+ return false;
+
+ return a->type == b->type;
+}
+
#endif
const struct drm_plane_state *plane_state)
{
struct intel_rotation_info *info = &view->rotation_info;
- static const struct i915_ggtt_view rotated_view =
- { .type = I915_GGTT_VIEW_ROTATED };
*view = i915_ggtt_view_normal;
if (!intel_rotation_90_or_270(plane_state->rotation))
return 0;
- *view = rotated_view;
+ *view = i915_ggtt_view_rotated;
info->height = fb->height;
info->pixel_format = fb->pixel_format;
unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
struct drm_i915_gem_object *obj)
{
- enum i915_ggtt_view_type view = I915_GGTT_VIEW_NORMAL;
+ const struct i915_ggtt_view *view = &i915_ggtt_view_normal;
if (intel_rotation_90_or_270(intel_plane->base.state->rotation))
- view = I915_GGTT_VIEW_ROTATED;
+ view = &i915_ggtt_view_rotated;
return i915_gem_obj_ggtt_offset_view(obj, view);
}