Linux Audio

Check our new training course

Yocto / OpenEmbedded training

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