Commit 08020509 authored by Daniel Stone's avatar Daniel Stone

drm/msm: Move GEM BOs to drm_framebuffer

Since drm_framebuffer can now store GEM objects directly, place them
there rather than in our own subclass. As this makes the framebuffer
create_handle function the same as the GEM framebuffer helper, we
can reuse that.
Signed-off-by: default avatarDaniel Stone <daniels@collabora.com>
Reviewed-by: default avatarThierry Reding <treding@nvidia.com>
Cc: Rob Clark <robdclark@gmail.com>
Cc: linux-arm-msm@vger.kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/20180330141138.28987-21-daniels@collabora.com
parent bc61c975
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <drm/drm_crtc.h> #include <drm/drm_crtc.h>
#include <drm/drm_crtc_helper.h> #include <drm/drm_crtc_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include "msm_drv.h" #include "msm_drv.h"
#include "msm_kms.h" #include "msm_kms.h"
...@@ -25,49 +26,20 @@ ...@@ -25,49 +26,20 @@
struct msm_framebuffer { struct msm_framebuffer {
struct drm_framebuffer base; struct drm_framebuffer base;
const struct msm_format *format; const struct msm_format *format;
struct drm_gem_object *planes[MAX_PLANE];
}; };
#define to_msm_framebuffer(x) container_of(x, struct msm_framebuffer, base) #define to_msm_framebuffer(x) container_of(x, struct msm_framebuffer, base)
static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev, static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos); const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
static int msm_framebuffer_create_handle(struct drm_framebuffer *fb,
struct drm_file *file_priv,
unsigned int *handle)
{
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
return drm_gem_handle_create(file_priv,
msm_fb->planes[0], handle);
}
static void msm_framebuffer_destroy(struct drm_framebuffer *fb)
{
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
int i, n = fb->format->num_planes;
DBG("destroy: FB ID: %d (%p)", fb->base.id, fb);
drm_framebuffer_cleanup(fb);
for (i = 0; i < n; i++) {
struct drm_gem_object *bo = msm_fb->planes[i];
drm_gem_object_put_unlocked(bo);
}
kfree(msm_fb);
}
static const struct drm_framebuffer_funcs msm_framebuffer_funcs = { static const struct drm_framebuffer_funcs msm_framebuffer_funcs = {
.create_handle = msm_framebuffer_create_handle, .create_handle = drm_gem_fb_create_handle,
.destroy = msm_framebuffer_destroy, .destroy = drm_gem_fb_destroy,
}; };
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m) void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
{ {
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
int i, n = fb->format->num_planes; int i, n = fb->format->num_planes;
seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n", seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n",
...@@ -77,7 +49,7 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m) ...@@ -77,7 +49,7 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
seq_printf(m, " %d: offset=%d pitch=%d, obj: ", seq_printf(m, " %d: offset=%d pitch=%d, obj: ",
i, fb->offsets[i], fb->pitches[i]); i, fb->offsets[i], fb->pitches[i]);
msm_gem_describe(msm_fb->planes[i], m); msm_gem_describe(fb->obj[i], m);
} }
} }
#endif #endif
...@@ -90,12 +62,11 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m) ...@@ -90,12 +62,11 @@ void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
int msm_framebuffer_prepare(struct drm_framebuffer *fb, int msm_framebuffer_prepare(struct drm_framebuffer *fb,
struct msm_gem_address_space *aspace) struct msm_gem_address_space *aspace)
{ {
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
int ret, i, n = fb->format->num_planes; int ret, i, n = fb->format->num_planes;
uint64_t iova; uint64_t iova;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
ret = msm_gem_get_iova(msm_fb->planes[i], aspace, &iova); ret = msm_gem_get_iova(fb->obj[i], aspace, &iova);
DBG("FB[%u]: iova[%d]: %08llx (%d)", fb->base.id, i, iova, ret); DBG("FB[%u]: iova[%d]: %08llx (%d)", fb->base.id, i, iova, ret);
if (ret) if (ret)
return ret; return ret;
...@@ -107,26 +78,23 @@ int msm_framebuffer_prepare(struct drm_framebuffer *fb, ...@@ -107,26 +78,23 @@ int msm_framebuffer_prepare(struct drm_framebuffer *fb,
void msm_framebuffer_cleanup(struct drm_framebuffer *fb, void msm_framebuffer_cleanup(struct drm_framebuffer *fb,
struct msm_gem_address_space *aspace) struct msm_gem_address_space *aspace)
{ {
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
int i, n = fb->format->num_planes; int i, n = fb->format->num_planes;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
msm_gem_put_iova(msm_fb->planes[i], aspace); msm_gem_put_iova(fb->obj[i], aspace);
} }
uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb, uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb,
struct msm_gem_address_space *aspace, int plane) struct msm_gem_address_space *aspace, int plane)
{ {
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb); if (!fb->obj[plane])
if (!msm_fb->planes[plane])
return 0; return 0;
return msm_gem_iova(msm_fb->planes[plane], aspace) + fb->offsets[plane]; return msm_gem_iova(fb->obj[plane], aspace) + fb->offsets[plane];
} }
struct drm_gem_object *msm_framebuffer_bo(struct drm_framebuffer *fb, int plane) struct drm_gem_object *msm_framebuffer_bo(struct drm_framebuffer *fb, int plane)
{ {
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb); return drm_gem_fb_get_obj(fb, plane);
return msm_fb->planes[plane];
} }
const struct msm_format *msm_framebuffer_format(struct drm_framebuffer *fb) const struct msm_format *msm_framebuffer_format(struct drm_framebuffer *fb)
...@@ -202,7 +170,7 @@ static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev, ...@@ -202,7 +170,7 @@ static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
msm_fb->format = format; msm_fb->format = format;
if (n > ARRAY_SIZE(msm_fb->planes)) { if (n > ARRAY_SIZE(fb->obj)) {
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;
} }
...@@ -221,7 +189,7 @@ static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev, ...@@ -221,7 +189,7 @@ static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
goto fail; goto fail;
} }
msm_fb->planes[i] = bos[i]; msm_fb->base.obj[i] = bos[i];
} }
drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd); drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment