pw_display_driver: Create DisplayDriver interface

Create a pw::display_driver::DisplayDriver interface for the
implementation of all display drivers.

Change-Id: I937ede0c22039bd727a36a4a0f52a74283ccab22
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/experimental/+/112871
Commit-Queue: Chris Mumford <cmumford@google.com>
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
diff --git a/build_overrides/pigweed.gni b/build_overrides/pigweed.gni
index 1c0f6e4..4ec70f6 100644
--- a/build_overrides/pigweed.gni
+++ b/build_overrides/pigweed.gni
@@ -36,6 +36,7 @@
   dir_pw_digital_io_stm32cube =
       get_path_info("//pw_digital_io_stm32cube", "abspath")
   dir_pw_display = get_path_info("//pw_graphics/pw_display", "abspath")
+  dir_pw_display_driver = get_path_info("//pw_display_driver", "abspath")
   dir_pw_display_driver_ili9341 =
       get_path_info("//pw_display_driver_ili9341", "abspath")
   dir_pw_display_host_imgui =
diff --git a/pw_display_driver/BUILD.gn b/pw_display_driver/BUILD.gn
new file mode 100644
index 0000000..5c72c5a
--- /dev/null
+++ b/pw_display_driver/BUILD.gn
@@ -0,0 +1,44 @@
+# Copyright 2022 The Pigweed Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+import("//build_overrides/pigweed.gni")
+
+import("$dir_pw_build/target_types.gni")
+import("$dir_pw_docgen/docs.gni")
+import("$dir_pw_unit_test/test.gni")
+
+config("public_include_path") {
+  include_dirs = [ "public" ]
+  visibility = [ ":*" ]
+}
+
+group("pw_display_driver") {
+  deps = [ ":display_driver" ]
+}
+
+pw_source_set("display_driver") {
+  public_configs = [ ":public_include_path" ]
+  public = [ "public/pw_display_driver/display_driver.h" ]
+  public_deps = [
+    "$dir_pw_framebuffer",
+    "$dir_pw_status",
+  ]
+}
+
+pw_test("display_driver_test") {
+}
+
+pw_doc_group("docs") {
+  sources = [ "docs.rst" ]
+}
diff --git a/pw_display_driver/docs.rst b/pw_display_driver/docs.rst
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/pw_display_driver/docs.rst
diff --git a/pw_display_driver/public/pw_display_driver/display_driver.h b/pw_display_driver/public/pw_display_driver/display_driver.h
new file mode 100644
index 0000000..6051296
--- /dev/null
+++ b/pw_display_driver/public/pw_display_driver/display_driver.h
@@ -0,0 +1,47 @@
+// Copyright 2022 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+#pragma once
+
+#include <cstddef>
+
+#include "pw_framebuffer/rgb565.h"
+#include "pw_status/status.h"
+
+namespace pw {
+namespace display_driver {
+
+// This interface defines a software display driver. This is the software
+// component responsible for *all* communications with a display controller.
+// The display controller is the hardware component of a display that
+// controls pixel values and other physical display properties.
+class DisplayDriver {
+ public:
+  virtual ~DisplayDriver() = default;
+
+  // Initialize the display controller.
+  virtual Status Init() = 0;
+
+  // Return the width supported by the display controller.
+  virtual int GetWidth() const = 0;
+
+  // Return the height supported by the display controller.
+  virtual int GetHeight() const = 0;
+
+  // Send all pixels in the supplied |framebuffer| to the display controller
+  // for display.
+  virtual Status Update(pw::framebuffer::FramebufferRgb565* framebuffer) = 0;
+};
+
+}  // namespace display_driver
+}  // namespace pw
diff --git a/pw_display_driver_ili9341/BUILD.gn b/pw_display_driver_ili9341/BUILD.gn
index fc09c8f..16044ee 100644
--- a/pw_display_driver_ili9341/BUILD.gn
+++ b/pw_display_driver_ili9341/BUILD.gn
@@ -25,13 +25,14 @@
   public_configs = [ ":default_config" ]
   public = [ "public/pw_display_driver_ili9341/display_driver.h" ]
   deps = [
-    "$dir_pw_digital_io",
-    "$dir_pw_framebuffer",
     "$dir_pw_log",
     "$dir_pw_spin_delay",
-    "$dir_pw_status",
   ]
-  public_deps = [ "$dir_pw_spi:device" ]
+  public_deps = [
+    "$dir_pw_digital_io",
+    "$dir_pw_display_driver:display_driver",
+    "$dir_pw_spi:device",
+  ]
   sources = [ "display_driver.cc" ]
   remove_configs = [ "$dir_pw_build:strict_warnings" ]
 }
diff --git a/pw_display_driver_ili9341/public/pw_display_driver_ili9341/display_driver.h b/pw_display_driver_ili9341/public/pw_display_driver_ili9341/display_driver.h
index 6698524..1217d86 100644
--- a/pw_display_driver_ili9341/public/pw_display_driver_ili9341/display_driver.h
+++ b/pw_display_driver_ili9341/public/pw_display_driver_ili9341/display_driver.h
@@ -16,35 +16,12 @@
 #include <cstddef>
 
 #include "pw_digital_io/digital_io.h"
-#include "pw_framebuffer/rgb565.h"
+#include "pw_display_driver/display_driver.h"
 #include "pw_spi/device.h"
-#include "pw_status/status.h"
 
 namespace pw {
 namespace display_driver {
 
-// This interface defines a software display driver. This is the software
-// component responsible for *all* communications with a display controller.
-// The display controller is the hardware component of a display that
-// controls pixel values and other physical display properties.
-class DisplayDriver {
- public:
-  virtual ~DisplayDriver() = default;
-
-  // Initialize the display controller.
-  virtual Status Init() = 0;
-
-  // Return the width supported by the display controller.
-  virtual int GetWidth() const = 0;
-
-  // Return the height supported by the display controller.
-  virtual int GetHeight() const = 0;
-
-  // Send all pixels in the supplied |framebuffer| to the display controller
-  // for display.
-  virtual Status Update(pw::framebuffer::FramebufferRgb565* framebuffer) = 0;
-};
-
 class DisplayDriverILI9341 : public DisplayDriver {
  public:
   // DisplayDriverILI9341 configuration parameters.