1 /* 2 * Copyright (C) 2019 Allwinnertech Co.Ltd 3 * Authors: zhengwanyu 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License as published by the 7 * Free Software Foundation; either version 2 of the License, or (at your 8 * option) any later version. 9 * 10 */ 11 12 #ifndef _SUNXI_DRM_CRTC_H_ 13 #define _SUNXI_DRM_CRTC_H_ 14 15 #include <drm/drm_crtc.h> 16 #include "drm/sunxi_drm.h" 17 18 #include "sunxi_drm_encoder.h" 19 #include "de/include.h" 20 #include "sunxi_device/sunxi_de.h" 21 22 enum enhance_mode { 23 ENHANCE_STANDARD = 0, 24 ENHANCE_VIVID = 1, 25 ENHANCE_SOFT = 2, 26 ENHANCE_DEMO_VIVID = 3, 27 ENHANCE_MAX, 28 }; 29 30 struct sunxi_drm_crtc { 31 struct drm_crtc crtc; 32 33 unsigned int crtc_id; 34 35 bool enabled; 36 37 /*NOTE: this is a ARRAY(!!!) of plane*/ 38 struct sunxi_drm_plane *plane; 39 40 /*overlay plane: in sunxi, 41 it means all of the planes except primary plane*/ 42 unsigned int overlay_plane_num; 43 44 /*primary plane + overlayer planes*/ 45 unsigned int plane_num; 46 47 /*the vblank event that is going to be sent*/ 48 struct drm_pending_vblank_event *event; 49 /*if there is plane that needs to be update in next vsync*/ 50 atomic_t update; 51 struct mutex update_reg_lock; 52 53 struct drm_property *support_smbl; 54 55 struct sunxi_de_funcs *hw_funcs; 56 57 /* There are common funcs that all kinds of encoders must implement. 58 * 59 * These funcs can be called by sunxi_drm_plane/crtc/encoder/connector. 60 * 61 * But these funcs can NOT be called by DRM CORE 62 * and sunxi hw layer, like sunxi_tv/lcd/hdmi. 63 */ 64 bool (*is_in_use)(struct sunxi_drm_crtc *scrtc); 65 void (*sw_enable)(struct sunxi_drm_crtc *scrtc); 66 int (*irq_register)(struct sunxi_drm_crtc *scrtc, 67 unsigned int irq_no); 68 void (*irq_unregister)(struct sunxi_drm_crtc *scrtc, 69 unsigned int irq_no); 70 bool (*encoder_is_supported)(struct sunxi_drm_crtc *scrtc, 71 struct sunxi_drm_encoder *senc); 72 }; 73 74 #define to_sunxi_crtc(x) container_of(x, struct sunxi_drm_crtc, crtc) 75 76 ssize_t sunxi_drm_crtc_show(char *buf, struct drm_device *dev); 77 struct sunxi_drm_crtc *sunxi_drm_crtc_get_crtc(int id); 78 unsigned int sunxi_drm_get_crtc_count(void); 79 80 int sunxi_drm_crtc_set_enhance_ioctl(struct drm_device *dev, 81 void *data, struct drm_file *file_priv); 82 int sunxi_drm_crtc_get_enhance_ioctl(struct drm_device *dev, 83 void *data, struct drm_file *file_priv); 84 int sunxi_drm_crtc_set_smbl_ioctl(struct drm_device *dev, 85 void *data, struct drm_file *file_priv); 86 int sunxi_drm_crtc_get_smbl_ioctl(struct drm_device *dev, 87 void *data, struct drm_file *file_priv); 88 89 int sunxi_drm_crtc_init(struct drm_device *dev); 90 void sunxi_drm_crtc_exit(struct drm_device *dev); 91 92 #endif 93