drm/fb-cma-helper: Add drm_fb_cma_get_gem_addr()
authorYannick Fertre <yannick.fertre@st.com>
Fri, 14 Apr 2017 10:13:32 +0000 (12:13 +0200)
committerEric Anholt <eric@anholt.net>
Fri, 14 Apr 2017 18:30:28 +0000 (11:30 -0700)
Add function drm_fb_cma_get_gem_addr() which return the physical address
of framebuffer (1st pixel). This function will usually be called by plane
callback (atomic_update).

Signed-off-by: Yannick Fertre <yannick.fertre@st.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Link: http://patchwork.freedesktop.org/patch/msgid/1492164819-10513-3-git-send-email-yannick.fertre@st.com
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
drivers/gpu/drm/drm_fb_cma_helper.c
include/drm/drm_fb_cma_helper.h

index 50abd1faf38f08681673cc09f2b290c6cf0d1aa3..d2b77b02830dfe0c94e1567e1af901030c5d83e6 100644 (file)
@@ -259,6 +259,33 @@ struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb,
 }
 EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj);
 
+/**
+ * drm_fb_cma_get_gem_addr() - Get physical address for framebuffer
+ * @fb: The framebuffer
+ * @state: Which state of drm plane
+ * @plane: Which plane
+ * Return the CMA GEM address for given framebuffer.
+ *
+ * This function will usually be called from the PLANE callback functions.
+ */
+dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
+                                  struct drm_plane_state *state,
+                                  unsigned int plane)
+{
+       struct drm_fb_cma *fb_cma = to_fb_cma(fb);
+       dma_addr_t paddr;
+
+       if (plane >= 4)
+               return 0;
+
+       paddr = fb_cma->obj[plane]->paddr + fb->offsets[plane];
+       paddr += fb->format->cpp[plane] * (state->src_x >> 16);
+       paddr += fb->pitches[plane] * (state->src_y >> 16);
+
+       return paddr;
+}
+EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_addr);
+
 /**
  * drm_fb_cma_prepare_fb() - Prepare CMA framebuffer
  * @plane: Which plane
index a5ecc0a582602cdf551cece988ee7348d75bdf9d..199a63f48659a8956bfe6350b1778e35c589a95b 100644 (file)
@@ -41,6 +41,10 @@ struct drm_framebuffer *drm_fb_cma_create(struct drm_device *dev,
 struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb,
        unsigned int plane);
 
+dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
+                                  struct drm_plane_state *state,
+                                  unsigned int plane);
+
 int drm_fb_cma_prepare_fb(struct drm_plane *plane,
                          struct drm_plane_state *state);