at v4.18 3.6 kB view raw
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 * @fb_funcs: Framebuffer functions used when creating framebuffers 23 */ 24struct tinydrm_device { 25 struct drm_device *drm; 26 struct drm_simple_display_pipe pipe; 27 struct mutex dirty_lock; 28 const struct drm_framebuffer_funcs *fb_funcs; 29 int (*fb_dirty)(struct drm_framebuffer *framebuffer, 30 struct drm_file *file_priv, unsigned flags, 31 unsigned color, struct drm_clip_rect *clips, 32 unsigned num_clips); 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_unlocked = tinydrm_gem_cma_free_object, \ 49 .gem_print_info = drm_gem_cma_print_info, \ 50 .gem_vm_ops = &drm_gem_cma_vm_ops, \ 51 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \ 52 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \ 53 .gem_prime_import = drm_gem_prime_import, \ 54 .gem_prime_export = drm_gem_prime_export, \ 55 .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, \ 56 .gem_prime_import_sg_table = tinydrm_gem_cma_prime_import_sg_table, \ 57 .gem_prime_vmap = drm_gem_cma_prime_vmap, \ 58 .gem_prime_vunmap = drm_gem_cma_prime_vunmap, \ 59 .gem_prime_mmap = drm_gem_cma_prime_mmap, \ 60 .dumb_create = drm_gem_cma_dumb_create 61 62/** 63 * TINYDRM_MODE - tinydrm display mode 64 * @hd: Horizontal resolution, width 65 * @vd: Vertical resolution, height 66 * @hd_mm: Display width in millimeters 67 * @vd_mm: Display height in millimeters 68 * 69 * This macro creates a &drm_display_mode for use with tinydrm. 70 */ 71#define TINYDRM_MODE(hd, vd, hd_mm, vd_mm) \ 72 .hdisplay = (hd), \ 73 .hsync_start = (hd), \ 74 .hsync_end = (hd), \ 75 .htotal = (hd), \ 76 .vdisplay = (vd), \ 77 .vsync_start = (vd), \ 78 .vsync_end = (vd), \ 79 .vtotal = (vd), \ 80 .width_mm = (hd_mm), \ 81 .height_mm = (vd_mm), \ 82 .type = DRM_MODE_TYPE_DRIVER, \ 83 .clock = 1 /* pass validation */ 84 85void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj); 86struct drm_gem_object * 87tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm, 88 struct dma_buf_attachment *attach, 89 struct sg_table *sgt); 90int devm_tinydrm_init(struct device *parent, struct tinydrm_device *tdev, 91 const struct drm_framebuffer_funcs *fb_funcs, 92 struct drm_driver *driver); 93int devm_tinydrm_register(struct tinydrm_device *tdev); 94void tinydrm_shutdown(struct tinydrm_device *tdev); 95 96void tinydrm_display_pipe_update(struct drm_simple_display_pipe *pipe, 97 struct drm_plane_state *old_state); 98int 99tinydrm_display_pipe_init(struct tinydrm_device *tdev, 100 const struct drm_simple_display_pipe_funcs *funcs, 101 int connector_type, 102 const uint32_t *formats, 103 unsigned int format_count, 104 const struct drm_display_mode *mode, 105 unsigned int rotation); 106 107#endif /* __LINUX_TINYDRM_H */