| .. | .. |
|---|
| 3 | 3 | #ifndef _VKMS_DRV_H_ |
|---|
| 4 | 4 | #define _VKMS_DRV_H_ |
|---|
| 5 | 5 | |
|---|
| 6 | | -#include <drm/drmP.h> |
|---|
| 6 | +#include <linux/hrtimer.h> |
|---|
| 7 | + |
|---|
| 7 | 8 | #include <drm/drm.h> |
|---|
| 8 | 9 | #include <drm/drm_gem.h> |
|---|
| 9 | 10 | #include <drm/drm_encoder.h> |
|---|
| 10 | | -#include <linux/hrtimer.h> |
|---|
| 11 | +#include <drm/drm_writeback.h> |
|---|
| 11 | 12 | |
|---|
| 12 | | -#define XRES_MIN 32 |
|---|
| 13 | | -#define YRES_MIN 32 |
|---|
| 13 | +#define XRES_MIN 20 |
|---|
| 14 | +#define YRES_MIN 20 |
|---|
| 14 | 15 | |
|---|
| 15 | 16 | #define XRES_DEF 1024 |
|---|
| 16 | 17 | #define YRES_DEF 768 |
|---|
| .. | .. |
|---|
| 18 | 19 | #define XRES_MAX 8192 |
|---|
| 19 | 20 | #define YRES_MAX 8192 |
|---|
| 20 | 21 | |
|---|
| 21 | | -static const u32 vkms_formats[] = { |
|---|
| 22 | | - DRM_FORMAT_XRGB8888, |
|---|
| 22 | +extern bool enable_cursor; |
|---|
| 23 | + |
|---|
| 24 | +struct vkms_composer { |
|---|
| 25 | + struct drm_framebuffer fb; |
|---|
| 26 | + struct drm_rect src, dst; |
|---|
| 27 | + unsigned int offset; |
|---|
| 28 | + unsigned int pitch; |
|---|
| 29 | + unsigned int cpp; |
|---|
| 30 | +}; |
|---|
| 31 | + |
|---|
| 32 | +/** |
|---|
| 33 | + * vkms_plane_state - Driver specific plane state |
|---|
| 34 | + * @base: base plane state |
|---|
| 35 | + * @composer: data required for composing computation |
|---|
| 36 | + */ |
|---|
| 37 | +struct vkms_plane_state { |
|---|
| 38 | + struct drm_plane_state base; |
|---|
| 39 | + struct vkms_composer *composer; |
|---|
| 40 | +}; |
|---|
| 41 | + |
|---|
| 42 | +/** |
|---|
| 43 | + * vkms_crtc_state - Driver specific CRTC state |
|---|
| 44 | + * @base: base CRTC state |
|---|
| 45 | + * @composer_work: work struct to compose and add CRC entries |
|---|
| 46 | + * @n_frame_start: start frame number for computed CRC |
|---|
| 47 | + * @n_frame_end: end frame number for computed CRC |
|---|
| 48 | + */ |
|---|
| 49 | +struct vkms_crtc_state { |
|---|
| 50 | + struct drm_crtc_state base; |
|---|
| 51 | + struct work_struct composer_work; |
|---|
| 52 | + |
|---|
| 53 | + int num_active_planes; |
|---|
| 54 | + /* stack of active planes for crc computation, should be in z order */ |
|---|
| 55 | + struct vkms_plane_state **active_planes; |
|---|
| 56 | + void *active_writeback; |
|---|
| 57 | + |
|---|
| 58 | + /* below four are protected by vkms_output.composer_lock */ |
|---|
| 59 | + bool crc_pending; |
|---|
| 60 | + bool wb_pending; |
|---|
| 61 | + u64 frame_start; |
|---|
| 62 | + u64 frame_end; |
|---|
| 23 | 63 | }; |
|---|
| 24 | 64 | |
|---|
| 25 | 65 | struct vkms_output { |
|---|
| 26 | 66 | struct drm_crtc crtc; |
|---|
| 27 | 67 | struct drm_encoder encoder; |
|---|
| 28 | 68 | struct drm_connector connector; |
|---|
| 69 | + struct drm_writeback_connector wb_connector; |
|---|
| 29 | 70 | struct hrtimer vblank_hrtimer; |
|---|
| 30 | 71 | ktime_t period_ns; |
|---|
| 31 | 72 | struct drm_pending_vblank_event *event; |
|---|
| 73 | + /* ordered wq for composer_work */ |
|---|
| 74 | + struct workqueue_struct *composer_workq; |
|---|
| 75 | + /* protects concurrent access to composer */ |
|---|
| 76 | + spinlock_t lock; |
|---|
| 77 | + |
|---|
| 78 | + /* protected by @lock */ |
|---|
| 79 | + bool composer_enabled; |
|---|
| 80 | + struct vkms_crtc_state *composer_state; |
|---|
| 81 | + |
|---|
| 82 | + spinlock_t composer_lock; |
|---|
| 32 | 83 | }; |
|---|
| 33 | 84 | |
|---|
| 34 | 85 | struct vkms_device { |
|---|
| .. | .. |
|---|
| 41 | 92 | struct drm_gem_object gem; |
|---|
| 42 | 93 | struct mutex pages_lock; /* Page lock used in page fault handler */ |
|---|
| 43 | 94 | struct page **pages; |
|---|
| 95 | + unsigned int vmap_count; |
|---|
| 96 | + void *vaddr; |
|---|
| 44 | 97 | }; |
|---|
| 45 | 98 | |
|---|
| 46 | 99 | #define drm_crtc_to_vkms_output(target) \ |
|---|
| .. | .. |
|---|
| 49 | 102 | #define drm_device_to_vkms_device(target) \ |
|---|
| 50 | 103 | container_of(target, struct vkms_device, drm) |
|---|
| 51 | 104 | |
|---|
| 105 | +#define drm_gem_to_vkms_gem(target)\ |
|---|
| 106 | + container_of(target, struct vkms_gem_object, gem) |
|---|
| 107 | + |
|---|
| 108 | +#define to_vkms_crtc_state(target)\ |
|---|
| 109 | + container_of(target, struct vkms_crtc_state, base) |
|---|
| 110 | + |
|---|
| 111 | +#define to_vkms_plane_state(target)\ |
|---|
| 112 | + container_of(target, struct vkms_plane_state, base) |
|---|
| 113 | + |
|---|
| 52 | 114 | /* CRTC */ |
|---|
| 53 | 115 | int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, |
|---|
| 54 | 116 | struct drm_plane *primary, struct drm_plane *cursor); |
|---|
| 55 | 117 | |
|---|
| 56 | | -bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe, |
|---|
| 57 | | - int *max_error, ktime_t *vblank_time, |
|---|
| 58 | | - bool in_vblank_irq); |
|---|
| 118 | +int vkms_output_init(struct vkms_device *vkmsdev, int index); |
|---|
| 59 | 119 | |
|---|
| 60 | | -int vkms_output_init(struct vkms_device *vkmsdev); |
|---|
| 61 | | - |
|---|
| 62 | | -struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev); |
|---|
| 120 | +struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev, |
|---|
| 121 | + enum drm_plane_type type, int index); |
|---|
| 63 | 122 | |
|---|
| 64 | 123 | /* Gem stuff */ |
|---|
| 65 | | -int vkms_gem_fault(struct vm_fault *vmf); |
|---|
| 124 | +vm_fault_t vkms_gem_fault(struct vm_fault *vmf); |
|---|
| 66 | 125 | |
|---|
| 67 | 126 | int vkms_dumb_create(struct drm_file *file, struct drm_device *dev, |
|---|
| 68 | 127 | struct drm_mode_create_dumb *args); |
|---|
| 69 | 128 | |
|---|
| 70 | | -int vkms_dumb_map(struct drm_file *file, struct drm_device *dev, |
|---|
| 71 | | - u32 handle, u64 *offset); |
|---|
| 72 | | - |
|---|
| 73 | 129 | void vkms_gem_free_object(struct drm_gem_object *obj); |
|---|
| 74 | 130 | |
|---|
| 131 | +int vkms_gem_vmap(struct drm_gem_object *obj); |
|---|
| 132 | + |
|---|
| 133 | +void vkms_gem_vunmap(struct drm_gem_object *obj); |
|---|
| 134 | + |
|---|
| 135 | +/* Prime */ |
|---|
| 136 | +struct drm_gem_object * |
|---|
| 137 | +vkms_prime_import_sg_table(struct drm_device *dev, |
|---|
| 138 | + struct dma_buf_attachment *attach, |
|---|
| 139 | + struct sg_table *sg); |
|---|
| 140 | + |
|---|
| 141 | +/* CRC Support */ |
|---|
| 142 | +const char *const *vkms_get_crc_sources(struct drm_crtc *crtc, |
|---|
| 143 | + size_t *count); |
|---|
| 144 | +int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name); |
|---|
| 145 | +int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name, |
|---|
| 146 | + size_t *values_cnt); |
|---|
| 147 | + |
|---|
| 148 | +/* Composer Support */ |
|---|
| 149 | +void vkms_composer_worker(struct work_struct *work); |
|---|
| 150 | +void vkms_set_composer(struct vkms_output *out, bool enabled); |
|---|
| 151 | + |
|---|
| 152 | +/* Writeback */ |
|---|
| 153 | +int vkms_enable_writeback_connector(struct vkms_device *vkmsdev); |
|---|
| 154 | + |
|---|
| 75 | 155 | #endif /* _VKMS_DRV_H_ */ |
|---|