Change some graphics build flags

While not all of these old build flags are active or implemented
yet (and they may not ever be implemeted until we find a device
that needs them), we need to make sure that the old build flags
are only applied when actually needed. Since there are a lot of
device trees that probably won't get updated due to lack of device
maintainers, we will rename the build flags and fix up devices on
a case by case basis.

Also added some pixel format related build flags to the make file
from AOSP so that AOSP devices should work in TWRP without
additional build flags.

Change-Id: I11ab475297d02b6aeffe89404fe50b4799a36be3
diff --git a/minuitwrp/Android.mk b/minuitwrp/Android.mk
index a05ab72..7f6b727 100644
--- a/minuitwrp/Android.mk
+++ b/minuitwrp/Android.mk
@@ -72,8 +72,8 @@
 LOCAL_CFLAGS += -DRECOVERY_TOUCHSCREEN_FLIP_Y
 endif
 
-ifeq ($(RECOVERY_GRAPHICS_USE_LINELENGTH), true)
-LOCAL_CFLAGS += -DRECOVERY_GRAPHICS_USE_LINELENGTH
+ifeq ($(RECOVERY_GRAPHICS_FORCE_USE_LINELENGTH), true)
+LOCAL_CFLAGS += -DRECOVERY_GRAPHICS_FORCE_USE_LINELENGTH
 endif
 
 ifeq ($(TW_DISABLE_DOUBLE_BUFFERING), true)
@@ -86,34 +86,50 @@
 LOCAL_CFLAGS += -D_EVENT_LOGGING
 endif
 
-ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),RGBA_8888)
+ifeq ($(subst ",,$(TARGET_RECOVERY_FORCE_PIXEL_FORMAT)),RGBA_8888)
+  $(warning ****************************************************************************)
+  $(warning * TARGET_RECOVERY_FORCE_PIXEL_FORMAT := RGBA_8888 not implemented yet      *)
+  $(warning ****************************************************************************)
+  $(error stopping)
   LOCAL_CFLAGS += -DRECOVERY_RGBA
 endif
+ifeq ($(subst ",,$(TARGET_RECOVERY_FORCE_PIXEL_FORMAT)),RGBX_8888)
+  $(warning ****************************************************************************)
+  $(warning * TARGET_RECOVERY_FORCE_PIXEL_FORMAT := RGBX_8888 not implemented yet      *)
+  $(warning ****************************************************************************)
+  $(error stopping)
+  LOCAL_CFLAGS += -DRECOVERY_RGBX
+endif
+ifeq ($(subst ",,$(TARGET_RECOVERY_FORCE_PIXEL_FORMAT)),BGRA_8888)
+  $(warning ****************************************************************************)
+  $(warning * TARGET_RECOVERY_FORCE_PIXEL_FORMAT := BGRA_8888 not implemented yet      *)
+  $(warning ****************************************************************************)
+  $(error stopping)
+  LOCAL_CFLAGS += -DRECOVERY_BGRA
+endif
+ifeq ($(subst ",,$(TARGET_RECOVERY_FORCE_PIXEL_FORMAT)),RGB_565)
+  LOCAL_CFLAGS += -DRECOVERY_FORCE_RGB_565
+endif
+
+# This used to compare against values in double-quotes (which are just
+# ordinary characters in this context).  Strip double-quotes from the
+# value so that either will work.
+
+ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),ABGR_8888)
+  LOCAL_CFLAGS += -DRECOVERY_ABGR
+endif
 ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),RGBX_8888)
   LOCAL_CFLAGS += -DRECOVERY_RGBX
 endif
 ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),BGRA_8888)
   LOCAL_CFLAGS += -DRECOVERY_BGRA
 endif
-ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),RGB_565)
-  LOCAL_CFLAGS += -DRECOVERY_RGB_565
-endif
 
 ifneq ($(TARGET_RECOVERY_OVERSCAN_PERCENT),)
   LOCAL_CFLAGS += -DOVERSCAN_PERCENT=$(TARGET_RECOVERY_OVERSCAN_PERCENT)
 else
   LOCAL_CFLAGS += -DOVERSCAN_PERCENT=0
 endif
-
-ifeq ($(TARGET_RECOVERY_PIXEL_FORMAT),"RGBX_8888")
-  LOCAL_CFLAGS += -DRECOVERY_RGBX
-endif
-ifeq ($(TARGET_RECOVERY_PIXEL_FORMAT),"BGRA_8888")
-  LOCAL_CFLAGS += -DRECOVERY_BGRA
-endif
-ifeq ($(TARGET_RECOVERY_PIXEL_FORMAT),"RGB_565")
-  LOCAL_CFLAGS += -DRECOVERY_RGB_565
-endif
 ifeq ($(TW_SCREEN_BLANK_ON_BOOT), true)
     LOCAL_CFLAGS += -DTW_SCREEN_BLANK_ON_BOOT
 endif
diff --git a/minuitwrp/graphics_fbdev.cpp b/minuitwrp/graphics_fbdev.cpp
index 5da329b..24294be 100644
--- a/minuitwrp/graphics_fbdev.cpp
+++ b/minuitwrp/graphics_fbdev.cpp
@@ -147,7 +147,7 @@
 
     memset(bits, 0, fi.smem_len);
 
-#ifdef RECOVERY_RGB_565
+#ifdef RECOVERY_FORCE_RGB_565
     printf("Forcing pixel format: RGB_565\n");
     vi.blue.offset    = 0;
     vi.green.offset   = 5;
@@ -167,7 +167,8 @@
     gr_framebuffer[0].height = vi.yres;
     gr_framebuffer[0].row_bytes = fi.line_length;
     gr_framebuffer[0].pixel_bytes = vi.bits_per_pixel / 8;
-#ifdef RECOVERY_GRAPHICS_USE_LINELENGTH
+#ifdef RECOVERY_GRAPHICS_FORCE_USE_LINELENGTH
+    printf("Forcing line length\n");
     vi.xres_virtual = fi.line_length / gr_framebuffer[0].pixel_bytes;
 #endif
     gr_framebuffer[0].data = reinterpret_cast<uint8_t*>(bits);