cregit-Linux how code gets into the kernel

Release 4.11 drivers/gpu/drm/msm/msm_fb.c

/*
 * Copyright (C) 2013 Red Hat
 * Author: Rob Clark <robdclark@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "msm_drv.h"
#include "msm_kms.h"

#include "drm_crtc.h"
#include "drm_crtc_helper.h"


struct msm_framebuffer {
	
struct drm_framebuffer base;
	
const struct msm_format *format;
	
struct drm_gem_object *planes[MAX_PLANE];
};

#define to_msm_framebuffer(x) container_of(x, struct msm_framebuffer, base)



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); }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark46100.00%1100.00%
Total46100.00%1100.00%


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_unreference_unlocked(bo); } kfree(msm_fb); }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark8496.55%150.00%
Ville Syrjälä33.45%150.00%
Total87100.00%2100.00%

static const struct drm_framebuffer_funcs msm_framebuffer_funcs = { .create_handle = msm_framebuffer_create_handle, .destroy = msm_framebuffer_destroy, }; #ifdef CONFIG_DEBUG_FS
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; seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n", fb->width, fb->height, (char *)&fb->format->format, drm_framebuffer_read_refcount(fb), fb->base.id); for (i = 0; i < n; i++) { seq_printf(m, " %d: offset=%d pitch=%d, obj: ", i, fb->offsets[i], fb->pitches[i]); msm_gem_describe(msm_fb->planes[i], m); } }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark11492.68%125.00%
Ville Syrjälä64.88%250.00%
Dave Airlie32.44%125.00%
Total123100.00%4100.00%

#endif /* prepare/pin all the fb's bo's for scanout. Note that it is not valid * to prepare an fb more multiple different initiator 'id's. But that * should be fine, since only the scanout (mdpN) side of things needs * this, the gpu doesn't care about fb's. */
int msm_framebuffer_prepare(struct drm_framebuffer *fb, int id) { struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb); int ret, i, n = fb->format->num_planes; uint64_t iova; for (i = 0; i < n; i++) { ret = msm_gem_get_iova(msm_fb->planes[i], id, &iova); DBG("FB[%u]: iova[%d]: %08llx (%d)", fb->base.id, i, iova, ret); if (ret) return ret; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark9596.94%266.67%
Ville Syrjälä33.06%133.33%
Total98100.00%3100.00%


void msm_framebuffer_cleanup(struct drm_framebuffer *fb, int id) { struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb); int i, n = fb->format->num_planes; for (i = 0; i < n; i++) msm_gem_put_iova(msm_fb->planes[i], id); }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark5694.92%150.00%
Ville Syrjälä35.08%150.00%
Total59100.00%2100.00%


uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb, int id, int plane) { struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb); if (!msm_fb->planes[plane]) return 0; return msm_gem_iova(msm_fb->planes[plane], id) + fb->offsets[plane]; }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark5288.14%266.67%
Stephane Viau711.86%133.33%
Total59100.00%3100.00%


struct drm_gem_object *msm_framebuffer_bo(struct drm_framebuffer *fb, int plane) { struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb); return msm_fb->planes[plane]; }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark33100.00%1100.00%
Total33100.00%1100.00%


const struct msm_format *msm_framebuffer_format(struct drm_framebuffer *fb) { struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb); return msm_fb->format; }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark28100.00%1100.00%
Total28100.00%1100.00%


struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev, struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd) { struct drm_gem_object *bos[4] = {0}; struct drm_framebuffer *fb; int ret, i, n = drm_format_num_planes(mode_cmd->pixel_format); for (i = 0; i < n; i++) { bos[i] = drm_gem_object_lookup(file, mode_cmd->handles[i]); if (!bos[i]) { ret = -ENXIO; goto out_unref; } } fb = msm_framebuffer_init(dev, mode_cmd, bos); if (IS_ERR(fb)) { ret = PTR_ERR(fb); goto out_unref; } return fb; out_unref: for (i = 0; i < n; i++) drm_gem_object_unreference_unlocked(bos[i]); return ERR_PTR(ret); }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark16599.40%150.00%
Ville Syrjälä10.60%150.00%
Total166100.00%2100.00%


struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos) { struct msm_drm_private *priv = dev->dev_private; struct msm_kms *kms = priv->kms; struct msm_framebuffer *msm_fb = NULL; struct drm_framebuffer *fb; const struct msm_format *format; int ret, i, n; unsigned int hsub, vsub; DBG("create framebuffer: dev=%p, mode_cmd=%p (%dx%d@%4.4s)", dev, mode_cmd, mode_cmd->width, mode_cmd->height, (char *)&mode_cmd->pixel_format); n = drm_format_num_planes(mode_cmd->pixel_format); hsub = drm_format_horz_chroma_subsampling(mode_cmd->pixel_format); vsub = drm_format_vert_chroma_subsampling(mode_cmd->pixel_format); format = kms->funcs->get_format(kms, mode_cmd->pixel_format); if (!format) { dev_err(dev->dev, "unsupported pixel format: %4.4s\n", (char *)&mode_cmd->pixel_format); ret = -EINVAL; goto fail; } msm_fb = kzalloc(sizeof(*msm_fb), GFP_KERNEL); if (!msm_fb) { ret = -ENOMEM; goto fail; } fb = &msm_fb->base; msm_fb->format = format; if (n > ARRAY_SIZE(msm_fb->planes)) { ret = -EINVAL; goto fail; } for (i = 0; i < n; i++) { unsigned int width = mode_cmd->width / (i ? hsub : 1); unsigned int height = mode_cmd->height / (i ? vsub : 1); unsigned int min_size; min_size = (height - 1) * mode_cmd->pitches[i] + width * drm_format_plane_cpp(mode_cmd->pixel_format, i) + mode_cmd->offsets[i]; if (bos[i]->size < min_size) { ret = -EINVAL; goto fail; } msm_fb->planes[i] = bos[i]; } drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd); ret = drm_framebuffer_init(dev, fb, &msm_framebuffer_funcs); if (ret) { dev_err(dev->dev, "framebuffer init failed: %d\n", ret); goto fail; } DBG("create: FB ID: %d (%p)", fb->base.id, fb); return fb; fail: kfree(msm_fb); return ERR_PTR(ret); }

Contributors

PersonTokensPropCommitsCommitProp
Rob Clark41698.35%240.00%
Stephane Viau40.95%120.00%
Ville Syrjälä30.71%240.00%
Total423100.00%5100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Rob Clark115597.14%642.86%
Ville Syrjälä191.60%428.57%
Stephane Viau121.01%321.43%
Dave Airlie30.25%17.14%
Total1189100.00%14100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.