[PATCH v7 2/9] drm/fb-cma-helper: Add drm_fb_cma_get_gem_addr()
Neil Armstrong
narmstrong at baylibre.com
Fri Apr 14 12:54:19 UTC 2017
On 04/14/2017 12:13 PM, Yannick Fertre wrote:
> 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 at st.com>
> ---
> drivers/gpu/drm/drm_fb_cma_helper.c | 27 +++++++++++++++++++++++++++
> include/drm/drm_fb_cma_helper.h | 4 ++++
> 2 files changed, 31 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
> index 50abd1f..d2b77b0 100644
> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> @@ -260,6 +260,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;
Nitpick, but why not using drm_fb_cma_get_gem_obj(fb, plane) here ?
=====
struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(fb, plane);
if (!gem)
return 0;
paddr = gem->paddr + fb->offsets[plane];
======
> +
> + 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
> * @state: Plane state attach fence to
> diff --git a/include/drm/drm_fb_cma_helper.h b/include/drm/drm_fb_cma_helper.h
> index a5ecc0a..199a63f 100644
> --- a/include/drm/drm_fb_cma_helper.h
> +++ b/include/drm/drm_fb_cma_helper.h
> @@ -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);
>
>
Anyway it's still ok,
Reviewed-by: Neil Armstrong <narmstrong at baylibre.com>
More information about the dri-devel
mailing list