summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'libhwcomposer/hwc.cpp')
-rw-r--r--libhwcomposer/hwc.cpp67
1 files changed, 40 insertions, 27 deletions
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 37e35b7..6a1b2a2 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,22 @@ static void get_connectors(omap_hwc_device_t* hwc_dev)
149 } 149 }
150} 150}
151 151
152static void setup_display_config(kms::Connector* connector, display_config_t *config,
153 kms::Videomode& videomode)
154{
155 config->xres = videomode.hdisplay;
156 config->yres = videomode.vdisplay;
157 config->fps = videomode.vrefresh;
158 config->xdpi = (unsigned int)((float)videomode.htotal/((float)connector->mmWidth() / MM_PER_INCH));
159 config->ydpi = (unsigned int)((float)videomode.vtotal/((float)connector->mmHeight() / MM_PER_INCH));
160
161 if (!config->xdpi)
162 config->xdpi = SECONDARY_DISPLAY_DEFAULT_DPI;
163
164 if (!config->ydpi)
165 config->ydpi = config->xdpi;
166}
167
152static int init_primary_display(omap_hwc_device_t* hwc_dev) 168static int init_primary_display(omap_hwc_device_t* hwc_dev)
153{ 169{
154 if (hwc_dev->displays[HWC_DISPLAY_PRIMARY]) { 170 if (hwc_dev->displays[HWC_DISPLAY_PRIMARY]) {
@@ -156,11 +172,10 @@ static int init_primary_display(omap_hwc_device_t* hwc_dev)
156 return -EBUSY; 172 return -EBUSY;
157 } 173 }
158 174
159 kms::Connector* connector = hwc_dev->primaryConector;
160
161 HWCDisplay* display = new HWCDisplay(DISP_ROLE_PRIMARY); 175 HWCDisplay* display = new HWCDisplay(DISP_ROLE_PRIMARY);
162 hwc_dev->displays[HWC_DISPLAY_PRIMARY] = display; 176 hwc_dev->displays[HWC_DISPLAY_PRIMARY] = display;
163 177
178 kms::Connector* connector = hwc_dev->primaryConector;
164 if (!connector) { 179 if (!connector) {
165 ALOGW("No connector found for primary display"); 180 ALOGW("No connector found for primary display");
166 ALOGW("Using dummy primary display"); 181 ALOGW("Using dummy primary display");
@@ -168,25 +183,28 @@ static int init_primary_display(omap_hwc_device_t* hwc_dev)
168 display->is_dummy = true; 183 display->is_dummy = true;
169 184
170 display_config_t config; 185 display_config_t config;
171 config.xres = LCD_DISPLAY_DEFAULT_HRES; 186
172 config.yres = LCD_DISPLAY_DEFAULT_VRES; 187 /*
173 config.fps = LCD_DISPLAY_DEFAULT_FPS; 188 * Configs for the external display should fit the dummy primary -
174 config.xdpi = LCD_DISPLAY_DEFAULT_DPI; 189 * Android often uses only primary display settings, despite the fact that
175 config.ydpi = LCD_DISPLAY_DEFAULT_DPI; 190 * external display is used instead
191 */
192 config.xres = SECONDARY_DISPLAY_DEFAULT_HRES;
193 config.yres = SECONDARY_DISPLAY_DEFAULT_VRES;
194 config.fps = SECONDARY_DISPLAY_DEFAULT_FPS;
195 config.xdpi = SECONDARY_DISPLAY_DEFAULT_DPI;
196 config.ydpi = SECONDARY_DISPLAY_DEFAULT_DPI;
197
176 display->configs.push_back(config); 198 display->configs.push_back(config);
177 199
178 return 0; 200 return 0;
179 } 201 }
180 202
181 /* Always use default mode for now */ 203 // FIXME: Allow selecting other modes until HWC 1.4 support is added
182 kms::Videomode mode = connector->get_default_mode(); 204 kms::Videomode mode = connector->get_default_mode();
183 205
184 display_config_t config; 206 display_config_t config;
185 config.xres = mode.hdisplay; 207 setup_display_config(connector, &config, mode);
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); 208 display->configs.push_back(config);
191 209
192 display->disp_link.card = hwc_dev->card; 210 display->disp_link.card = hwc_dev->card;
@@ -210,7 +228,6 @@ static int add_external_hdmi_display(omap_hwc_device_t* hwc_dev)
210 } 228 }
211 229
212 kms::Connector* connector = hwc_dev->externalConector; 230 kms::Connector* connector = hwc_dev->externalConector;
213
214 if (!connector) { 231 if (!connector) {
215 ALOGE("No connector for external display"); 232 ALOGE("No connector for external display");
216 return -1; 233 return -1;
@@ -221,18 +238,14 @@ static int add_external_hdmi_display(omap_hwc_device_t* hwc_dev)
221 connector->refresh(); 238 connector->refresh();
222 } while (connector->get_modes().size() == 0); 239 } while (connector->get_modes().size() == 0);
223 240
224 // FIXME: Allow selecting other modes until HWC 1.4 support is added
225 kms::Videomode mode = connector->get_default_mode();
226
227 HWCDisplay* display = new HWCDisplay(DISP_ROLE_SECONDARY); 241 HWCDisplay* display = new HWCDisplay(DISP_ROLE_SECONDARY);
228 hwc_dev->displays[HWC_DISPLAY_EXTERNAL] = display; 242 hwc_dev->displays[HWC_DISPLAY_EXTERNAL] = display;
229 243
244 // FIXME: Allow selecting other modes until HWC 1.4 support is added
245 kms::Videomode mode = connector->get_default_mode();
246
230 display_config_t config; 247 display_config_t config;
231 config.xres = mode.hdisplay; 248 setup_display_config(connector, &config, mode);
232 config.yres = mode.vdisplay;
233 config.fps = mode.vrefresh;
234 config.xdpi = HDMI_DISPLAY_DEFAULT_DPI;
235 config.ydpi = HDMI_DISPLAY_DEFAULT_DPI;
236 display->configs.push_back(config); 249 display->configs.push_back(config);
237 250
238 display->disp_link.card = hwc_dev->card; 251 display->disp_link.card = hwc_dev->card;