[vim][display] Add some consts/fwd_decls.
Clean up a few of the header files to be a bit more rigourous. Specifically...
++ Add some const flags to some of the function signatures which do
not need to actually modify a vim2_display_t structure passed to them.
++ Forward declare the vim2_display structure in a few places so that
header files can be independently included or included in any order.
++ Surround the C sections of header files with BEGIN/END_CDECLS
++ Also define a DWC HDMI register that was missing.
Test: Build only
Change-Id: I177ce68ee7c6c3ac00255cf1932c7c3d2582294d
diff --git a/system/dev/display/vim-display/dwc-hdmi.h b/system/dev/display/vim-display/dwc-hdmi.h
index 371b106..4cabff7 100644
--- a/system/dev/display/vim-display/dwc-hdmi.h
+++ b/system/dev/display/vim-display/dwc-hdmi.h
@@ -434,6 +434,7 @@
#define HDMITX_DWC_AUD_SPDIF1 (DWC_OFFSET_MASK + 0x3301)
#define HDMITX_DWC_AUD_SPDIFINT (DWC_OFFSET_MASK + 0x3302)
#define HDMITX_DWC_AUD_SPDIFINT1 (DWC_OFFSET_MASK + 0x3303)
+#define HDMITX_DWC_AUD_SPDIF2 (DWC_OFFSET_MASK + 0x3304)
#define HDMITX_DWC_MC_CLKDIS (DWC_OFFSET_MASK + 0x4001)
#define HDMITX_DWC_MC_SWRSTZREQ (DWC_OFFSET_MASK + 0x4002)
#define HDMITX_DWC_MC_OPCTRL (DWC_OFFSET_MASK + 0x4003)
@@ -624,4 +625,4 @@
#define HDMITX_DWC_HDCPREG_DPK4 (DWC_SEC_OFFSET_MASK + 0x7816)
#define HDMITX_DWC_HDCPREG_DPK5 (DWC_SEC_OFFSET_MASK + 0x7817)
#define HDMITX_DWC_HDCPREG_DPK6 (DWC_SEC_OFFSET_MASK + 0x7818)
-#define HDMITX_DWC_HDCP22REG_CTRL (DWC_SEC_OFFSET_MASK + 0x7904)
\ No newline at end of file
+#define HDMITX_DWC_HDCP22REG_CTRL (DWC_SEC_OFFSET_MASK + 0x7904)
diff --git a/system/dev/display/vim-display/hdmitx.c b/system/dev/display/vim-display/hdmitx.c
index 999ddd9..ebefaed 100644
--- a/system/dev/display/vim-display/hdmitx.c
+++ b/system/dev/display/vim-display/hdmitx.c
@@ -26,7 +26,7 @@
// #define LOG_HDMITX
-void hdmitx_writereg(vim2_display_t* display, uint32_t addr, uint32_t data) {
+void hdmitx_writereg(const vim2_display_t* display, uint32_t addr, uint32_t data) {
// determine if we are writing to HDMI TOP (AMLOGIC Wrapper) or HDMI IP
uint32_t offset = (addr & DWC_OFFSET_MASK) >> 24;
addr = addr & 0xffff;
@@ -39,7 +39,7 @@
#endif
}
-uint32_t hdmitx_readreg(vim2_display_t* display, uint32_t addr) {
+uint32_t hdmitx_readreg(const vim2_display_t* display, uint32_t addr) {
// determine if we are writing to HDMI TOP (AMLOGIC Wrapper) or HDMI IP
uint32_t offset = (addr & DWC_OFFSET_MASK) >> 24;
addr = addr & 0xffff;
diff --git a/system/dev/display/vim-display/hdmitx.h b/system/dev/display/vim-display/hdmitx.h
index 62d51a9..2b3d64b 100644
--- a/system/dev/display/vim-display/hdmitx.h
+++ b/system/dev/display/vim-display/hdmitx.h
@@ -18,6 +18,8 @@
#include "vpu.h"
#include "dwc-hdmi.h"
+__BEGIN_CDECLS
+
#define DISPLAY_MASK(start, count) (((1 << (count)) - 1) << (start))
#define DISPLAY_SET_MASK(mask, start, count, value) \
((mask & ~DISPLAY_MASK(start, count)) | \
@@ -306,12 +308,16 @@
#define VIC_VESA_800x600p_60Hz 304
#define VIC_VESA_1024x768p_60Hz 305
-void hdmitx_writereg(vim2_display_t* display, uint32_t addr, uint32_t data);
-uint32_t hdmitx_readreg(vim2_display_t* display, uint32_t addr);
-zx_status_t init_hdmi_hardware(vim2_display_t* display);
-void dump_regs(vim2_display_t* display);
-zx_status_t init_hdmi_interface(vim2_display_t* display, const struct hdmi_param* p);
-void hdmi_test(vim2_display_t* display, uint32_t width);
-zx_status_t configure_pll(vim2_display_t* display, const struct hdmi_param* p,
+struct vim2_display; // fwd decl
+
+void hdmitx_writereg(const struct vim2_display* display, uint32_t addr, uint32_t data);
+uint32_t hdmitx_readreg(const struct vim2_display* display, uint32_t addr);
+zx_status_t init_hdmi_hardware(struct vim2_display* display);
+void dump_regs(struct vim2_display* display);
+zx_status_t init_hdmi_interface(struct vim2_display* display, const struct hdmi_param* p);
+void hdmi_test(struct vim2_display* display, uint32_t width);
+zx_status_t configure_pll(struct vim2_display* display, const struct hdmi_param* p,
const struct pll_param* pll);
-void hdmi_shutdown(vim2_display_t* display);
+void hdmi_shutdown(struct vim2_display* display);
+
+__END_CDECLS
diff --git a/system/dev/display/vim-display/vim-display.h b/system/dev/display/vim-display/vim-display.h
index c4527e5..8018a99 100644
--- a/system/dev/display/vim-display/vim-display.h
+++ b/system/dev/display/vim-display/vim-display.h
@@ -28,7 +28,7 @@
#define VFIFO2VD_TO_HDMI_LATENCY 2
#define EDID_BUF_SIZE 256
-typedef struct {
+typedef struct vim2_display {
zx_device_t* zxdev;
platform_device_protocol_t pdev;
zx_device_t* parent;