summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'libhwcomposer/hwc.cpp')
-rw-r--r--libhwcomposer/hwc.cpp85
1 files changed, 56 insertions, 29 deletions
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index c2d5206..c88064a 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -35,12 +35,12 @@
35#include "format.h" 35#include "format.h"
36#include "hwc_dev.h" 36#include "hwc_dev.h"
37 37
38#define LCD_DISPLAY_DEFAULT_HRES 1920 38#define SECONDARY_DISPLAY_DEFAULT_HRES 1920
39#define LCD_DISPLAY_DEFAULT_VRES 1080 39#define SECONDARY_DISPLAY_DEFAULT_VRES 1080
40#define LCD_DISPLAY_DEFAULT_FPS 60 40#define SECONDARY_DISPLAY_DEFAULT_FPS 60
41#define SECONDARY_DISPLAY_DEFAULT_DPI 160
41 42
42#define LCD_DISPLAY_DEFAULT_DPI 120 43#define MM_PER_INCH 25.4f
43#define HDMI_DISPLAY_DEFAULT_DPI 75
44 44
45#define HWC_PRIORITY_LOW_DISPLAY (19) 45#define HWC_PRIORITY_LOW_DISPLAY (19)
46 46
@@ -149,6 +149,34 @@ static void get_connectors(omap_hwc_device_t* hwc_dev)
149 } 149 }
150} 150}
151 151
152static int setup_display_config(kms::Connector* connector, display_config_t *config,
153 kms::Videomode *mode)
154{
155 if(!connector) {
156 ALOGW("Can not adjust config - connector is null.");
157 return -1;
158 }
159
160 // FIXME: Allow selecting other modes until HWC 1.4 support is added
161 kms::Videomode videomode = connector->get_default_mode();
162
163 config->xres = videomode.hdisplay;
164 config->yres = videomode.vdisplay;
165 config->fps = videomode.vrefresh;
166 config->xdpi = (unsigned int)((float)videomode.htotal/((float)connector->mmWidth() / MM_PER_INCH));
167 config->ydpi = (unsigned int)((float)videomode.vtotal/((float)connector->mmHeight() / MM_PER_INCH));
168
169 if (!config->xdpi)
170 config->xdpi = SECONDARY_DISPLAY_DEFAULT_DPI;
171
172 if (!config->ydpi)
173 config->ydpi = config->ydpi;
174
175 *mode = videomode;
176
177 return 0;
178}
179
152static int init_primary_display(omap_hwc_device_t* hwc_dev) 180static int init_primary_display(omap_hwc_device_t* hwc_dev)
153{ 181{
154 if (hwc_dev->displays[HWC_DISPLAY_PRIMARY]) { 182 if (hwc_dev->displays[HWC_DISPLAY_PRIMARY]) {
@@ -156,37 +184,37 @@ static int init_primary_display(omap_hwc_device_t* hwc_dev)
156 return -EBUSY; 184 return -EBUSY;
157 } 185 }
158 186
187 display_config_t config;
188 kms::Videomode mode;
159 kms::Connector* connector = hwc_dev->primaryConector; 189 kms::Connector* connector = hwc_dev->primaryConector;
160
161 HWCDisplay* display = new HWCDisplay(DISP_ROLE_PRIMARY); 190 HWCDisplay* display = new HWCDisplay(DISP_ROLE_PRIMARY);
162 hwc_dev->displays[HWC_DISPLAY_PRIMARY] = display; 191 hwc_dev->displays[HWC_DISPLAY_PRIMARY] = display;
163 192
164 if (!connector) { 193 if (setup_display_config(connector, &config, &mode)) {
165 ALOGW("No connector found for primary display"); 194 ALOGW("No connector found for primary display");
166 ALOGW("Using dummy primary display"); 195 ALOGW("Using dummy primary display");
167 196
168 display->is_dummy = true; 197 display->is_dummy = true;
169 198
170 display_config_t config; 199 display_config_t config;
171 config.xres = LCD_DISPLAY_DEFAULT_HRES; 200
172 config.yres = LCD_DISPLAY_DEFAULT_VRES; 201 /*
173 config.fps = LCD_DISPLAY_DEFAULT_FPS; 202 * Configs for the external display should fit the dummy primary -
174 config.xdpi = LCD_DISPLAY_DEFAULT_DPI; 203 * Android often uses only primary display settings, despite the fact that
175 config.ydpi = LCD_DISPLAY_DEFAULT_DPI; 204 * external display is used instead - we will be able to see corruptions of
205 * correspinding UI elements in that case
206 */
207 config.xres = SECONDARY_DISPLAY_DEFAULT_HRES;
208 config.yres = SECONDARY_DISPLAY_DEFAULT_VRES;
209 config.fps = SECONDARY_DISPLAY_DEFAULT_FPS;
210 config.xdpi = SECONDARY_DISPLAY_DEFAULT_DPI;
211 config.ydpi = SECONDARY_DISPLAY_DEFAULT_DPI;
212
176 display->configs.push_back(config); 213 display->configs.push_back(config);
177 214
178 return 0; 215 return 0;
179 } 216 }
180 217
181 /* Always use default mode for now */
182 kms::Videomode mode = connector->get_default_mode();
183
184 display_config_t config;
185 config.xres = mode.hdisplay;
186 config.yres = mode.vdisplay;
187 config.fps = mode.vrefresh;
188 config.xdpi = LCD_DISPLAY_DEFAULT_DPI;
189 config.ydpi = LCD_DISPLAY_DEFAULT_DPI;
190 display->configs.push_back(config); 218 display->configs.push_back(config);
191 219
192 display->disp_link.card = hwc_dev->card; 220 display->disp_link.card = hwc_dev->card;
@@ -209,6 +237,7 @@ static int add_external_hdmi_display(omap_hwc_device_t* hwc_dev)
209 return 0; 237 return 0;
210 } 238 }
211 239
240 kms::Videomode mode;
212 kms::Connector* connector = hwc_dev->externalConector; 241 kms::Connector* connector = hwc_dev->externalConector;
213 242
214 if (!connector) { 243 if (!connector) {
@@ -221,18 +250,16 @@ static int add_external_hdmi_display(omap_hwc_device_t* hwc_dev)
221 connector->refresh(); 250 connector->refresh();
222 } while (connector->get_modes().size() == 0); 251 } while (connector->get_modes().size() == 0);
223 252
224 // FIXME: Allow selecting other modes until HWC 1.4 support is added 253 display_config_t config;
225 kms::Videomode mode = connector->get_default_mode();
226 254
227 HWCDisplay* display = new HWCDisplay(DISP_ROLE_SECONDARY); 255 HWCDisplay* display = new HWCDisplay(DISP_ROLE_SECONDARY);
228 hwc_dev->displays[HWC_DISPLAY_EXTERNAL] = display; 256 hwc_dev->displays[HWC_DISPLAY_EXTERNAL] = display;
229 257
230 display_config_t config; 258 if (setup_display_config(connector, &config, &mode)) {
231 config.xres = mode.hdisplay; 259 ALOGE("Failed to setup config.");
232 config.yres = mode.vdisplay; 260 return -1;
233 config.fps = mode.vrefresh; 261 }
234 config.xdpi = HDMI_DISPLAY_DEFAULT_DPI; 262
235 config.ydpi = HDMI_DISPLAY_DEFAULT_DPI;
236 display->configs.push_back(config); 263 display->configs.push_back(config);
237 264
238 display->disp_link.card = hwc_dev->card; 265 display->disp_link.card = hwc_dev->card;