2019-02-06 21:01:16 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
|
|
|
2018-05-14 21:33:46 +07:00
|
|
|
#ifndef _VKMS_DRV_H_
|
|
|
|
#define _VKMS_DRV_H_
|
|
|
|
|
2018-05-17 06:56:21 +07:00
|
|
|
#include <drm/drmP.h>
|
|
|
|
#include <drm/drm.h>
|
2018-07-12 09:01:47 +07:00
|
|
|
#include <drm/drm_gem.h>
|
2018-05-17 06:56:21 +07:00
|
|
|
#include <drm/drm_encoder.h>
|
2018-07-12 09:02:26 +07:00
|
|
|
#include <linux/hrtimer.h>
|
2018-05-17 06:56:21 +07:00
|
|
|
|
2018-09-06 12:17:16 +07:00
|
|
|
#define XRES_MIN 20
|
|
|
|
#define YRES_MIN 20
|
2018-07-12 09:02:14 +07:00
|
|
|
|
|
|
|
#define XRES_DEF 1024
|
|
|
|
#define YRES_DEF 768
|
|
|
|
|
|
|
|
#define XRES_MAX 8192
|
|
|
|
#define YRES_MAX 8192
|
|
|
|
|
2018-09-06 12:19:11 +07:00
|
|
|
extern bool enable_cursor;
|
|
|
|
|
2018-08-02 08:10:26 +07:00
|
|
|
struct vkms_crc_data {
|
|
|
|
struct drm_framebuffer fb;
|
2018-09-06 12:18:26 +07:00
|
|
|
struct drm_rect src, dst;
|
|
|
|
unsigned int offset;
|
|
|
|
unsigned int pitch;
|
|
|
|
unsigned int cpp;
|
2018-08-02 08:10:26 +07:00
|
|
|
};
|
|
|
|
|
2018-08-02 08:08:22 +07:00
|
|
|
/**
|
|
|
|
* vkms_plane_state - Driver specific plane state
|
|
|
|
* @base: base plane state
|
2018-08-02 08:10:26 +07:00
|
|
|
* @crc_data: data required for CRC computation
|
2018-08-02 08:08:22 +07:00
|
|
|
*/
|
|
|
|
struct vkms_plane_state {
|
|
|
|
struct drm_plane_state base;
|
2018-08-02 08:10:26 +07:00
|
|
|
struct vkms_crc_data *crc_data;
|
2018-08-02 08:08:22 +07:00
|
|
|
};
|
|
|
|
|
2018-07-24 23:31:05 +07:00
|
|
|
/**
|
|
|
|
* vkms_crtc_state - Driver specific CRTC state
|
|
|
|
* @base: base CRTC state
|
2018-08-02 08:10:26 +07:00
|
|
|
* @crc_work: work struct to compute and add CRC entries
|
2018-09-04 04:18:17 +07:00
|
|
|
* @n_frame_start: start frame number for computed CRC
|
|
|
|
* @n_frame_end: end frame number for computed CRC
|
2018-07-24 23:31:05 +07:00
|
|
|
*/
|
|
|
|
struct vkms_crtc_state {
|
|
|
|
struct drm_crtc_state base;
|
2018-08-02 08:10:26 +07:00
|
|
|
struct work_struct crc_work;
|
2018-09-04 04:18:17 +07:00
|
|
|
u64 frame_start;
|
|
|
|
u64 frame_end;
|
2018-07-24 23:31:05 +07:00
|
|
|
};
|
|
|
|
|
2018-05-17 06:56:21 +07:00
|
|
|
struct vkms_output {
|
|
|
|
struct drm_crtc crtc;
|
|
|
|
struct drm_encoder encoder;
|
|
|
|
struct drm_connector connector;
|
2018-07-12 09:02:26 +07:00
|
|
|
struct hrtimer vblank_hrtimer;
|
|
|
|
ktime_t period_ns;
|
|
|
|
struct drm_pending_vblank_event *event;
|
2018-08-02 08:10:26 +07:00
|
|
|
bool crc_enabled;
|
|
|
|
/* ordered wq for crc_work */
|
|
|
|
struct workqueue_struct *crc_workq;
|
|
|
|
/* protects concurrent access to crc_data */
|
|
|
|
spinlock_t lock;
|
2018-09-04 04:18:17 +07:00
|
|
|
/* protects concurrent access to crtc_state */
|
|
|
|
spinlock_t state_lock;
|
2018-05-17 06:56:21 +07:00
|
|
|
};
|
2018-05-14 21:33:46 +07:00
|
|
|
|
|
|
|
struct vkms_device {
|
|
|
|
struct drm_device drm;
|
|
|
|
struct platform_device *platform;
|
2018-05-17 06:56:21 +07:00
|
|
|
struct vkms_output output;
|
2018-05-14 21:33:46 +07:00
|
|
|
};
|
|
|
|
|
2018-07-12 09:01:47 +07:00
|
|
|
struct vkms_gem_object {
|
|
|
|
struct drm_gem_object gem;
|
|
|
|
struct mutex pages_lock; /* Page lock used in page fault handler */
|
|
|
|
struct page **pages;
|
2018-07-24 23:26:59 +07:00
|
|
|
unsigned int vmap_count;
|
|
|
|
void *vaddr;
|
2018-07-12 09:01:47 +07:00
|
|
|
};
|
|
|
|
|
2018-07-12 09:02:26 +07:00
|
|
|
#define drm_crtc_to_vkms_output(target) \
|
|
|
|
container_of(target, struct vkms_output, crtc)
|
|
|
|
|
|
|
|
#define drm_device_to_vkms_device(target) \
|
|
|
|
container_of(target, struct vkms_device, drm)
|
|
|
|
|
2018-07-24 23:26:59 +07:00
|
|
|
#define drm_gem_to_vkms_gem(target)\
|
|
|
|
container_of(target, struct vkms_gem_object, gem)
|
|
|
|
|
2018-07-24 23:31:05 +07:00
|
|
|
#define to_vkms_crtc_state(target)\
|
|
|
|
container_of(target, struct vkms_crtc_state, base)
|
|
|
|
|
2018-08-02 08:08:22 +07:00
|
|
|
#define to_vkms_plane_state(target)\
|
|
|
|
container_of(target, struct vkms_plane_state, base)
|
|
|
|
|
2018-07-12 09:02:26 +07:00
|
|
|
/* CRTC */
|
2018-05-17 06:56:21 +07:00
|
|
|
int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
|
|
|
|
struct drm_plane *primary, struct drm_plane *cursor);
|
|
|
|
|
2018-07-12 09:02:26 +07:00
|
|
|
bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
|
|
|
|
int *max_error, ktime_t *vblank_time,
|
|
|
|
bool in_vblank_irq);
|
|
|
|
|
2018-05-17 06:56:21 +07:00
|
|
|
int vkms_output_init(struct vkms_device *vkmsdev);
|
|
|
|
|
2018-09-06 12:17:16 +07:00
|
|
|
struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev,
|
|
|
|
enum drm_plane_type type);
|
2018-05-17 06:56:21 +07:00
|
|
|
|
2018-07-12 09:01:47 +07:00
|
|
|
/* Gem stuff */
|
|
|
|
struct drm_gem_object *vkms_gem_create(struct drm_device *dev,
|
|
|
|
struct drm_file *file,
|
|
|
|
u32 *handle,
|
|
|
|
u64 size);
|
|
|
|
|
2018-07-26 21:45:49 +07:00
|
|
|
vm_fault_t vkms_gem_fault(struct vm_fault *vmf);
|
2018-07-12 09:01:47 +07:00
|
|
|
|
|
|
|
int vkms_dumb_create(struct drm_file *file, struct drm_device *dev,
|
|
|
|
struct drm_mode_create_dumb *args);
|
|
|
|
|
|
|
|
void vkms_gem_free_object(struct drm_gem_object *obj);
|
|
|
|
|
2018-07-24 23:26:59 +07:00
|
|
|
int vkms_gem_vmap(struct drm_gem_object *obj);
|
|
|
|
|
|
|
|
void vkms_gem_vunmap(struct drm_gem_object *obj);
|
|
|
|
|
2018-08-02 08:10:26 +07:00
|
|
|
/* CRC Support */
|
2018-08-21 15:38:56 +07:00
|
|
|
int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name);
|
2018-08-21 15:38:55 +07:00
|
|
|
int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
|
|
|
|
size_t *values_cnt);
|
2018-08-02 08:10:26 +07:00
|
|
|
void vkms_crc_work_handle(struct work_struct *work);
|
|
|
|
|
2018-05-14 21:33:46 +07:00
|
|
|
#endif /* _VKMS_DRV_H_ */
|