1c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner/* Copyright (C) 2009 The Android Open Source Project 2c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner** 3c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner** This software is licensed under the terms of the GNU General Public 4c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner** License version 2, as published by the Free Software Foundation, and 5c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner** may be copied, distributed, and modified under those terms. 6c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner** 7c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner** This program is distributed in the hope that it will be useful, 8c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner** but WITHOUT ANY WARRANTY; without even the implied warranty of 9c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner** GNU General Public License for more details. 11c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner*/ 12c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner#include "android/hw-lcd.h" 13c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner#include "android/boot-properties.h" 14c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner#include <stdio.h> 15c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner 16c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turnervoid 17c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' TurnerhwLcd_setBootProperty(int density) 18c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner{ 19c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner char temp[8]; 20c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner 21049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet /* Map density to one of our five bucket values. 22049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet The TV density is a bit particular (and not actually a bucket 23049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet value) so we do only exact match on it. 24049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet */ 25049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet if (density != LCD_DENSITY_TVDPI) { 26049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet if (density < (LCD_DENSITY_LDPI + LCD_DENSITY_MDPI)/2) 27049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet density = LCD_DENSITY_LDPI; 28049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet else if (density < (LCD_DENSITY_MDPI + LCD_DENSITY_HDPI)/2) 29049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet density = LCD_DENSITY_MDPI; 30049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet else if (density < (LCD_DENSITY_HDPI + LCD_DENSITY_XHDPI)/2) 31049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet density = LCD_DENSITY_HDPI; 32049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet else 33049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet density = LCD_DENSITY_XHDPI; 34049c72f0ffd9381b88bf9477fc41df5fc8c9a2a1Xavier Ducrohet } 35c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner 36c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner snprintf(temp, sizeof temp, "%d", density); 37c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner boot_property_add("qemu.sf.lcd_density", temp); 38c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner} 39c5b127050f2dbed015d6b01703a33062d6910d4aDavid 'Digit' Turner 40