linux/include/drm/tinydrm/tinydrm.h
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2016 Noralf Trønnes
   3 *
   4 * This program is free software; you can redistribute it and/or modify
   5 * it under the terms of the GNU General Public License as published by
   6 * the Free Software Foundation; either version 2 of the License, or
   7 * (at your option) any later version.
   8 */
   9
  10#ifndef __LINUX_TINYDRM_H
  11#define __LINUX_TINYDRM_H
  12
  13#include <drm/drm_gem_cma_helper.h>
  14#include <drm/drm_fb_cma_helper.h>
  15#include <drm/drm_simple_kms_helper.h>
  16
  17/**
  18 * struct tinydrm_device - tinydrm device
  19 * @drm: DRM device
  20 * @pipe: Display pipe structure
  21 * @dirty_lock: Serializes framebuffer flushing
  22 * @fbdev_cma: CMA fbdev structure
  23 * @suspend_state: Atomic state when suspended
  24 * @fb_funcs: Framebuffer functions used when creating framebuffers
  25 */
  26struct tinydrm_device {
  27        struct drm_device *drm;
  28        struct drm_simple_display_pipe pipe;
  29        struct mutex dirty_lock;
  30        struct drm_fbdev_cma *fbdev_cma;
  31        struct drm_atomic_state *suspend_state;
  32        const struct drm_framebuffer_funcs *fb_funcs;
  33};
  34
  35static inline struct tinydrm_device *
  36pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
  37{
  38        return container_of(pipe, struct tinydrm_device, pipe);
  39}
  40
  41/**
  42 * TINYDRM_GEM_DRIVER_OPS - default tinydrm gem operations
  43 *
  44 * This macro provides a shortcut for setting the tinydrm GEM operations in
  45 * the &drm_driver structure.
  46 */
  47#define TINYDRM_GEM_DRIVER_OPS \
  48        .gem_free_object        = tinydrm_gem_cma_free_object, \
  49        .gem_vm_ops             = &drm_gem_cma_vm_ops, \
  50        .prime_handle_to_fd     = drm_gem_prime_handle_to_fd, \
  51        .prime_fd_to_handle     = drm_gem_prime_fd_to_handle, \
  52        .gem_prime_import       = drm_gem_prime_import, \
  53        .gem_prime_export       = drm_gem_prime_export, \
  54        .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, \
  55        .gem_prime_import_sg_table = tinydrm_gem_cma_prime_import_sg_table, \
  56        .gem_prime_vmap         = drm_gem_cma_prime_vmap, \
  57        .gem_prime_vunmap       = drm_gem_cma_prime_vunmap, \
  58        .gem_prime_mmap         = drm_gem_cma_prime_mmap, \
  59        .dumb_create            = drm_gem_cma_dumb_create, \
  60        .dumb_map_offset        = drm_gem_cma_dumb_map_offset, \
  61        .dumb_destroy           = drm_gem_dumb_destroy, \
  62        .fops                   = &tinydrm_fops
  63
  64/**
  65 * TINYDRM_MODE - tinydrm display mode
  66 * @hd: Horizontal resolution, width
  67 * @vd: Vertical resolution, height
  68 * @hd_mm: Display width in millimeters
  69 * @vd_mm: Display height in millimeters
  70 *
  71 * This macro creates a &drm_display_mode for use with tinydrm.
  72 */
  73#define TINYDRM_MODE(hd, vd, hd_mm, vd_mm) \
  74        .hdisplay = (hd), \
  75        .hsync_start = (hd), \
  76        .hsync_end = (hd), \
  77        .htotal = (hd), \
  78        .vdisplay = (vd), \
  79        .vsync_start = (vd), \
  80        .vsync_end = (vd), \
  81        .vtotal = (vd), \
  82        .width_mm = (hd_mm), \
  83        .height_mm = (vd_mm), \
  84        .type = DRM_MODE_TYPE_DRIVER, \
  85        .clock = 1 /* pass validation */
  86
  87extern const struct file_operations tinydrm_fops;
  88void tinydrm_lastclose(struct drm_device *drm);
  89void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj);
  90struct drm_gem_object *
  91tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,
  92                                      struct dma_buf_attachment *attach,
  93                                      struct sg_table *sgt);
  94int devm_tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
  95                      const struct drm_framebuffer_funcs *fb_funcs,
  96                      struct drm_driver *driver);
  97int devm_tinydrm_register(struct tinydrm_device *tdev);
  98void tinydrm_shutdown(struct tinydrm_device *tdev);
  99int tinydrm_suspend(struct tinydrm_device *tdev);
 100int tinydrm_resume(struct tinydrm_device *tdev);
 101
 102void tinydrm_display_pipe_update(struct drm_simple_display_pipe *pipe,
 103                                 struct drm_plane_state *old_state);
 104int tinydrm_display_pipe_prepare_fb(struct drm_simple_display_pipe *pipe,
 105                                    struct drm_plane_state *plane_state);
 106int
 107tinydrm_display_pipe_init(struct tinydrm_device *tdev,
 108                          const struct drm_simple_display_pipe_funcs *funcs,
 109                          int connector_type,
 110                          const uint32_t *formats,
 111                          unsigned int format_count,
 112                          const struct drm_display_mode *mode,
 113                          unsigned int rotation);
 114
 115#endif /* __LINUX_TINYDRM_H */
 116