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_CONNECTOR_H_ 13 #define _SUNXI_DRM_CONNECTOR_H_ 14 15 #include <drm/drm_modes.h> 16 #include <drm/drm_connector.h> 17 #include <video/sunxi_display2.h> 18 #include "sunxi_device/sunxi_common.h" 19 20 #define MAX_CONNECTOR_COUNT 10 21 22 struct sunxi_drm_connector { 23 struct drm_connector connector; 24 25 /*index of connectors*/ 26 unsigned int con_id; 27 28 unsigned int type; 29 30 /*index of a certain type of connector 31 *for example, if type = lcd, type_id = 2, 32 * it means that this connector is lcd2 33 */ 34 unsigned int type_id; 35 36 bool use_irq; 37 unsigned int irq_no; 38 39 /*mainly used by tv/hdmi/edp*/ 40 struct sunxi_connector_work_mode work_mode; 41 42 void *hw_funcs; 43 44 /* There are common funcs that all kinds of connectors must implement. 45 * 46 * These funcs can be called by sunxi_drm_plane/crtc/encoder/connector. 47 * 48 * But these funcs can NOT be called by DRM CORE 49 * and sunxi hw layer, like sunxi_tv/lcd/hdmi. 50 */ 51 void (*get_init_resolution)( 52 struct sunxi_drm_connector *sconn, 53 unsigned int *w, unsigned int *h, unsigned int *vfresh); 54 55 struct drm_display_mode *(*get_init_mode)( 56 struct sunxi_drm_connector *sconn); 57 58 void (*get_work_mode)(struct sunxi_drm_connector *sconn, 59 struct sunxi_connector_work_mode *mode); 60 61 int (*get_video_timing)(struct disp_video_timings *timing, 62 struct drm_display_mode *mode); 63 64 int (*enable)(struct sunxi_drm_connector *sconn, 65 struct drm_display_mode *mode); 66 int (*sw_enable)(struct sunxi_drm_connector *sconn, 67 struct drm_display_mode *mode); 68 void (*disable)(struct sunxi_drm_connector *sconn); 69 }; 70 71 #if defined(CONFIG_AW_DRM_HDMI14) || defined(CONFIG_AW_DRM_HDMI20) 72 #if defined(CONFIG_AW_DRM_HDMI14) 73 #include "sunxi_device/sunxi_hdmi14.h" 74 #elif defined(CONFIG_AW_DRM_HDMI20) 75 #include "sunxi_device/sunxi_hdmi20.h" 76 #endif 77 78 struct sunxi_drm_hdmi_connector { 79 struct sunxi_drm_connector sunxi_conn; 80 81 /*indicate hdmi current working mode*/ 82 struct sunxi_hdmi_work_mode work_mode; 83 84 struct drm_property *hdmi_mode_property; 85 struct drm_property *color_fmt_property; 86 struct drm_property *color_depth_property; 87 struct drm_property *color_space_property; 88 struct drm_property *eotf_property; 89 struct drm_property *color_range_property; 90 struct drm_property *aspect_ratio_property; 91 }; 92 #endif 93 94 #define to_sunxi_connector(x) \ 95 (container_of(x, struct sunxi_drm_connector, connector)) 96 97 extern void drm_get_displayid(struct drm_connector *connector, 98 struct edid *edid); 99 100 101 /*These funcs bellows will be called by sunxi_drm_plane/crtc/encoder*/ 102 unsigned int sunxi_drm_connector_get_count(void); 103 ssize_t sunxi_drm_connector_show(char *buf, struct drm_device *dev); 104 struct sunxi_drm_connector * 105 sunxi_drm_connector_get_connector(int id); 106 void 107 sunxi_drm_connector_set_connector(int id, struct sunxi_drm_connector *conn); 108 109 int sunxi_drm_connector_init(struct drm_device *dev); 110 void sunxi_drm_connector_exit(struct drm_device *dev); 111 112 113 /*These funcs bellows will be called by sunxi_drm_lcd/tv/hdmi_connector*/ 114 struct drm_encoder * 115 sunxi_connector_best_encoder(struct drm_connector *connector); 116 117 118 /*These funcs bellows will be called by sunxi_drm_connector*/ 119 struct sunxi_drm_connector * 120 sunxi_drm_connector_lcd_create(struct drm_device *dev, int conn_id, int lcd_id); 121 struct sunxi_drm_connector * 122 sunxi_drm_connector_tv_create(struct drm_device *dev, int conn_id, int tv_id); 123 struct sunxi_drm_connector * 124 sunxi_drm_connector_hdmi_create(struct drm_device *dev, int conn_id); 125 126 unsigned int 127 sunxi_drm_connector_hdmi_get_color_format(struct drm_connector *connector); 128 129 extern unsigned int drm_debug; 130 extern bool drm_edid_block_valid(u8 *raw_edid, int block, 131 bool print_bad_edid, bool *edid_corrupt); 132 #endif 133