aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2021-10-08 19:54:12 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-10-08 19:54:12 +0000
commit8b89e51b5c42abee4722c57a1942734c2c522239 (patch)
tree17c08f5f8b24d5f67164654772a735500197864e
parente72ea2cee9d4c0f1cd13cec51407aa87147f0082 (diff)
parentbee0cd7e08a3da6b45173c80b7d75f085ccddf25 (diff)
downloadcuttlefish-8b89e51b5c42abee4722c57a1942734c2c522239.tar.gz
Merge "Make dpi and refresh rate configurable per display" into sc-v2-dev
-rw-r--r--common/libs/device_config/host_device_config.cpp5
-rw-r--r--host/commands/assemble_cvd/flags.cc33
-rw-r--r--host/frontend/webrtc/main.cpp2
-rw-r--r--host/libs/config/bootconfig_args.cpp8
-rw-r--r--host/libs/config/cuttlefish_config.cpp19
-rw-r--r--host/libs/config/cuttlefish_config.h8
6 files changed, 48 insertions, 27 deletions
diff --git a/common/libs/device_config/host_device_config.cpp b/common/libs/device_config/host_device_config.cpp
index 35ec27ff1..eb28c63dc 100644
--- a/common/libs/device_config/host_device_config.cpp
+++ b/common/libs/device_config/host_device_config.cpp
@@ -163,8 +163,9 @@ void InitializeScreenConfiguration(const CuttlefishConfig& cuttlefish_config,
device_display_config->set_width(cuttlefish_display_config.width);
device_display_config->set_height(cuttlefish_display_config.height);
- device_display_config->set_dpi(cuttlefish_config.dpi());
- device_display_config->set_refresh_rate_hz(cuttlefish_config.refresh_rate_hz());
+ device_display_config->set_dpi(cuttlefish_display_config.dpi);
+ device_display_config->set_refresh_rate_hz(
+ cuttlefish_display_config.refresh_rate_hz);
}
}
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index 8439031da..f66852bb5 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -57,9 +57,15 @@ DEFINE_int32(gdb_port, 0,
"disabled.");
constexpr const char kDisplayHelp[] =
- "Comma separated key-value pairs of display properties. Example usage: "
- "--display0=width=1280,height=720 "
- "--display1=width=1440,height=900 ";
+ "Comma separated key=value pairs of display properties. Supported "
+ "properties:\n"
+ " 'width': required, width of the display in pixels\n"
+ " 'height': required, height of the display in pixels\n"
+ " 'dpi': optional, default 320, density of the display\n"
+ " 'refresh_rate_hz': optional, default 60, display refresh rate in Hertz\n"
+ ". Example usage: \n"
+ "--display0=width=1280,height=720\n"
+ "--display1=width=1440,height=900,dpi=480,refresh_rate_hz=30\n";
// TODO(b/192495477): combine these into a single repeatable '--display' flag
// when assemble_cvd switches to using the new flag parsing library.
@@ -384,9 +390,26 @@ std::optional<CuttlefishConfig::DisplayConfig> ParseDisplayConfig(
CHECK(android::base::ParseInt(props["height"], &display_height))
<< "Display configuration invalid 'height' in " << flag;
+ int display_dpi = 320;
+ auto display_dpi_it = props.find("dpi");
+ if (display_dpi_it != props.end()) {
+ CHECK(android::base::ParseInt(display_dpi_it->second, &display_dpi))
+ << "Display configuration invalid 'dpi' in " << flag;
+ }
+
+ int display_refresh_rate_hz = 60;
+ auto display_refresh_rate_hz_it = props.find("refresh_rate_hz");
+ if (display_refresh_rate_hz_it != props.end()) {
+ CHECK(android::base::ParseInt(display_refresh_rate_hz_it->second,
+ &display_refresh_rate_hz))
+ << "Display configuration invalid 'refresh_rate_hz' in " << flag;
+ }
+
return CuttlefishConfig::DisplayConfig{
.width = display_width,
.height = display_height,
+ .dpi = display_dpi,
+ .refresh_rate_hz = display_refresh_rate_hz,
};
}
@@ -485,6 +508,8 @@ CuttlefishConfig InitializeCuttlefishConfiguration(
display_configs.push_back({
.width = FLAGS_x_res,
.height = FLAGS_y_res,
+ .dpi = FLAGS_dpi,
+ .refresh_rate_hz = FLAGS_refresh_rate_hz,
});
} else {
LOG(WARNING) << "Ignoring --x_res and --y_res when --displayN specified.";
@@ -492,8 +517,6 @@ CuttlefishConfig InitializeCuttlefishConfiguration(
}
tmp_config_obj.set_display_configs(display_configs);
- tmp_config_obj.set_dpi(FLAGS_dpi);
- tmp_config_obj.set_refresh_rate_hz(FLAGS_refresh_rate_hz);
const GraphicsAvailability graphics_availability =
GetGraphicsAvailabilityWithSubprocessCheck();
diff --git a/host/frontend/webrtc/main.cpp b/host/frontend/webrtc/main.cpp
index 96a1b15a8..57d5644bf 100644
--- a/host/frontend/webrtc/main.cpp
+++ b/host/frontend/webrtc/main.cpp
@@ -236,7 +236,7 @@ int main(int argc, char** argv) {
auto display =
streamer->AddDisplay(display_id, display_config.width,
- display_config.height, cvd_config->dpi(), true);
+ display_config.height, display_config.dpi, true);
displays.push_back(display);
++display_index;
diff --git a/host/libs/config/bootconfig_args.cpp b/host/libs/config/bootconfig_args.cpp
index 151cc937e..1f926eb36 100644
--- a/host/libs/config/bootconfig_args.cpp
+++ b/host/libs/config/bootconfig_args.cpp
@@ -90,7 +90,13 @@ std::vector<std::string> BootconfigArgsFromConfig(
bootconfig_args.push_back(
concat("androidboot.serialno=", instance.serial_number()));
- bootconfig_args.push_back(concat("androidboot.lcd_density=", config.dpi()));
+
+ // TODO(b/131884992): update to specify multiple once supported.
+ const auto display_configs = config.display_configs();
+ CHECK_GE(display_configs.size(), 1);
+ bootconfig_args.push_back(
+ concat("androidboot.lcd_density=", display_configs[0].dpi));
+
bootconfig_args.push_back(
concat("androidboot.setupwizard_mode=", config.setupwizard_mode()));
if (!config.guest_enforce_security()) {
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index 2b899bc9f..b5160d0bc 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -123,13 +123,11 @@ void CuttlefishConfig::set_memory_mb(int memory_mb) {
(*dictionary_)[kMemoryMb] = memory_mb;
}
-static constexpr char kDpi[] = "dpi";
-int CuttlefishConfig::dpi() const { return (*dictionary_)[kDpi].asInt(); }
-void CuttlefishConfig::set_dpi(int dpi) { (*dictionary_)[kDpi] = dpi; }
-
static constexpr char kDisplayConfigs[] = "display_configs";
static constexpr char kXRes[] = "x_res";
static constexpr char kYRes[] = "y_res";
+static constexpr char kDpi[] = "dpi";
+static constexpr char kRefreshRateHz[] = "refresh_rate_hz";
std::vector<CuttlefishConfig::DisplayConfig>
CuttlefishConfig::display_configs() const {
std::vector<DisplayConfig> display_configs;
@@ -137,6 +135,9 @@ CuttlefishConfig::display_configs() const {
DisplayConfig display_config = {};
display_config.width = display_config_json[kXRes].asInt();
display_config.height = display_config_json[kYRes].asInt();
+ display_config.dpi = display_config_json[kDpi].asInt();
+ display_config.refresh_rate_hz =
+ display_config_json[kRefreshRateHz].asInt();
display_configs.emplace_back(std::move(display_config));
}
return display_configs;
@@ -149,20 +150,14 @@ void CuttlefishConfig::set_display_configs(
Json::Value display_config_json(Json::objectValue);
display_config_json[kXRes] = display_configs.width;
display_config_json[kYRes] = display_configs.height;
+ display_config_json[kDpi] = display_configs.dpi;
+ display_config_json[kRefreshRateHz] = display_configs.refresh_rate_hz;
display_configs_json.append(display_config_json);
}
(*dictionary_)[kDisplayConfigs] = display_configs_json;
}
-static constexpr char kRefreshRateHz[] = "refresh_rate_hz";
-int CuttlefishConfig::refresh_rate_hz() const {
- return (*dictionary_)[kRefreshRateHz].asInt();
-}
-void CuttlefishConfig::set_refresh_rate_hz(int refresh_rate_hz) {
- (*dictionary_)[kRefreshRateHz] = refresh_rate_hz;
-}
-
void CuttlefishConfig::SetPath(const std::string& key,
const std::string& path) {
if (!path.empty()) {
diff --git a/host/libs/config/cuttlefish_config.h b/host/libs/config/cuttlefish_config.h
index 2028874ef..db3207ef8 100644
--- a/host/libs/config/cuttlefish_config.h
+++ b/host/libs/config/cuttlefish_config.h
@@ -103,15 +103,11 @@ class CuttlefishConfig {
int memory_mb() const;
void set_memory_mb(int memory_mb);
- int dpi() const;
- void set_dpi(int dpi);
-
- int refresh_rate_hz() const;
- void set_refresh_rate_hz(int refresh_rate_hz);
-
struct DisplayConfig {
int width;
int height;
+ int dpi;
+ int refresh_rate_hz;
};
std::vector<DisplayConfig> display_configs() const;