1 /* 2 * Copyright (c) 2011 Intel Corporation. All Rights Reserved. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the 6 * "Software"), to deal in the Software without restriction, including 7 * without limitation the rights to use, copy, modify, merge, publish, 8 * distribute, sub license, and/or sell copies of the Software, and to 9 * permit persons to whom the Software is furnished to do so, subject to 10 * the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the 13 * next paragraph) shall be included in all copies or substantial portions 14 * of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 * 24 * Authors: 25 * Jason Hu <jason.hu (at) intel.com> 26 * Zhaohan Ren <zhaohan.ren (at) intel.com> 27 * 28 */ 29 30 31 #ifndef _PSB_XRANDR_H_ 32 #define _PSB_XRANDR_H_ 33 #include <stdio.h> 34 #include <X11/Xlib.h> 35 #include <X11/Xlibint.h> 36 #include <X11/Xproto.h> 37 #include <X11/Xatom.h> 38 #include <X11/extensions/Xrandr.h> 39 #include <X11/extensions/Xrender.h> /* we share subpixel information */ 40 #include <pthread.h> 41 #include <string.h> 42 #include <stdlib.h> 43 #include <stdarg.h> 44 #include <math.h> 45 #include <va/va_backend.h> 46 47 typedef enum _psb_output_device { 48 MIPI0, 49 MIPI1, 50 LVDS0, 51 HDMI, 52 } psb_output_device; 53 54 typedef enum _psb_output_device_mode { 55 SINGLE_MIPI0, 56 SINGLE_MIPI1, 57 SINGLE_HDMI, 58 SINGLE_LVDS0, 59 MIPI0_MIPI1, 60 MIPI0_HDMI, 61 MIPI0_MIPI1_HDMI, 62 MIPI1_HDMI, 63 } psb_output_device_mode; 64 65 typedef enum _psb_hdmi_mode { 66 CLONE, 67 EXTENDED, 68 EXTENDEDVIDEO, 69 SINGLE, 70 UNKNOWNVIDEOMODE, 71 } psb_hdmi_mode; 72 73 typedef enum _psb_extvideo_center { 74 NOCENTER, 75 CENTER, 76 UNKNOWNCENTER, 77 } psb_extvideo_center; 78 79 typedef enum _psb_extvideo_subtitle { 80 BOTH, 81 ONLY_HDMI, 82 NOSUBTITLE, 83 } psb_extvideo_subtitle; 84 85 typedef enum _psb_xrandr_location { 86 NORMAL, ABOVE, BELOW, LEFT_OF, RIGHT_OF, 87 } psb_xrandr_location; 88 89 typedef struct _psb_extvideo_prop_s { 90 psb_hdmi_mode ExtVideoMode; 91 psb_hdmi_mode ExtDesktopMode; 92 93 unsigned int ExtVideoMode_XRes; 94 unsigned int ExtVideoMode_YRes; 95 unsigned int ExtVideoMode_X_Offset; 96 unsigned int ExtVideoMode_Y_Offset; 97 unsigned int OverscanMode; 98 unsigned int PANELFITTING; 99 100 psb_extvideo_center ExtVideoMode_Center; 101 psb_extvideo_subtitle ExtVideoMode_SubTitle; 102 103 } psb_extvideo_prop_s, *psb_extvideo_prop_p; 104 105 typedef struct _psb_xrandr_crtc_s { 106 struct _psb_xrandr_crtc_s *next; 107 108 RRCrtc crtc_id; 109 RRMode crtc_mode; 110 111 unsigned int width; 112 unsigned int height; 113 unsigned int x; 114 unsigned int y; 115 116 Rotation rotation; 117 psb_xrandr_location location; 118 119 int noutput; 120 121 } psb_xrandr_crtc_s, *psb_xrandr_crtc_p; 122 123 typedef struct _psb_xrandr_output_s { 124 RROutput output_id; 125 char name[10]; 126 struct _psb_xrandr_output_s *next; 127 128 Connection connection; 129 130 psb_xrandr_crtc_p crtc; 131 132 } psb_xrandr_output_s, *psb_xrandr_output_p; 133 134 typedef struct _psb_xrandr_info_s { 135 psb_xrandr_crtc_p local_crtc[2]; 136 psb_xrandr_crtc_p extend_crtc; 137 138 psb_xrandr_output_p local_output[2]; 139 psb_xrandr_output_p extend_output; 140 141 unsigned int nconnected_output; 142 143 psb_extvideo_prop_p hdmi_extvideo_prop; 144 145 int lvds0_enabled; 146 int mipi0_enabled; 147 int mipi1_enabled; 148 int hdmi_enabled; 149 150 Rotation mipi0_rotation; 151 Rotation mipi1_rotation; 152 Rotation hdmi_rotation; 153 154 int output_changed; 155 psb_output_device_mode output_device_mode; 156 157 psb_xrandr_crtc_p crtc_head, crtc_tail; 158 psb_xrandr_output_p output_head, output_tail; 159 160 pthread_mutex_t psb_extvideo_mutex; 161 XRRScreenResources *res; 162 Display *dpy; 163 Window root; 164 Atom psb_exit_atom; 165 } psb_xrandr_info_s, *psb_xrandr_info_p; 166 167 168 int psb_xrandr_hdmi_enabled(); 169 int psb_xrandr_mipi1_enabled(); 170 int psb_xrandr_single_mode(); 171 int psb_xrandr_clone_mode(); 172 int psb_xrandr_extend_mode(); 173 int psb_xrandr_extvideo_mode(); 174 int psb_xrandr_outputchanged(); 175 176 Window psb_xrandr_create_full_screen_window(unsigned int destx, unsigned int desty, unsigned int destw, unsigned int desth); 177 VAStatus psb_xrandr_extvideo_prop(unsigned int *xres, unsigned int *yres, unsigned int *xoffset, 178 unsigned int *yoffset, psb_extvideo_center *center, psb_extvideo_subtitle *subtitle, 179 unsigned int *overscanmode, unsigned int *pannelfitting); 180 VAStatus psb_xrandr_local_crtc_coordinate(psb_output_device *local_device_enabled, int *x, int *y, int *width, int *height, Rotation *rotation); 181 VAStatus psb_xrandr_extend_crtc_coordinate(psb_output_device *extend_device_enabled, int *x, int *y, int *width, int *height, psb_xrandr_location *location, Rotation *rotation); 182 183 void psb_xrandr_refresh(VADriverContextP ctx); 184 void psb_xrandr_thread(); 185 VAStatus psb_xrandr_thread_create(VADriverContextP ctx); 186 VAStatus psb_xrandr_thread_exit(); 187 VAStatus psb_xrandr_init(VADriverContextP ctx); 188 VAStatus psb_xrandr_deinit(); 189 190 #endif /* _PSB_XRANDR_H_ */ 191