David 'Digit' Turner | c5b1270 | 2009-06-19 00:36:12 +0200 | [diff] [blame] | 1 | /* Copyright (C) 2009 The Android Open Source Project |
| 2 | ** |
| 3 | ** This software is licensed under the terms of the GNU General Public |
| 4 | ** License version 2, as published by the Free Software Foundation, and |
| 5 | ** may be copied, distributed, and modified under those terms. |
| 6 | ** |
| 7 | ** This program is distributed in the hope that it will be useful, |
| 8 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | ** GNU General Public License for more details. |
| 11 | */ |
| 12 | #include "android/hw-lcd.h" |
| 13 | #include "android/boot-properties.h" |
| 14 | #include <stdio.h> |
| 15 | |
| 16 | void |
| 17 | hwLcd_setBootProperty(int density) |
| 18 | { |
| 19 | char temp[8]; |
| 20 | |
Xavier Ducrohet | 049c72f | 2011-06-03 11:24:32 -0700 | [diff] [blame] | 21 | /* Map density to one of our five bucket values. |
| 22 | The TV density is a bit particular (and not actually a bucket |
| 23 | value) so we do only exact match on it. |
| 24 | */ |
| 25 | if (density != LCD_DENSITY_TVDPI) { |
| 26 | if (density < (LCD_DENSITY_LDPI + LCD_DENSITY_MDPI)/2) |
| 27 | density = LCD_DENSITY_LDPI; |
| 28 | else if (density < (LCD_DENSITY_MDPI + LCD_DENSITY_HDPI)/2) |
| 29 | density = LCD_DENSITY_MDPI; |
| 30 | else if (density < (LCD_DENSITY_HDPI + LCD_DENSITY_XHDPI)/2) |
| 31 | density = LCD_DENSITY_HDPI; |
Stuart Scott | 77fe764 | 2014-01-13 10:25:20 -0800 | [diff] [blame] | 32 | else if (density < (LCD_DENSITY_XHDPI + LCD_DENSITY_400DPI)/2) |
Xavier Ducrohet | 049c72f | 2011-06-03 11:24:32 -0700 | [diff] [blame] | 33 | density = LCD_DENSITY_XHDPI; |
Stuart Scott | 77fe764 | 2014-01-13 10:25:20 -0800 | [diff] [blame] | 34 | else if (density < (LCD_DENSITY_400DPI + LCD_DENSITY_XXHDPI)/2) |
| 35 | density = LCD_DENSITY_400DPI; |
Deepanshu Gupta | 7703f55 | 2013-11-11 18:33:35 +0530 | [diff] [blame] | 36 | else if (density < (LCD_DENSITY_XXHDPI + LCD_DENSITY_XXXHDPI)/2) |
| 37 | density = LCD_DENSITY_XXHDPI; |
| 38 | else |
| 39 | density = LCD_DENSITY_XXXHDPI; |
Xavier Ducrohet | 049c72f | 2011-06-03 11:24:32 -0700 | [diff] [blame] | 40 | } |
David 'Digit' Turner | c5b1270 | 2009-06-19 00:36:12 +0200 | [diff] [blame] | 41 | |
| 42 | snprintf(temp, sizeof temp, "%d", density); |
| 43 | boot_property_add("qemu.sf.lcd_density", temp); |
| 44 | } |
| 45 | |