Skip to content

Commit

Permalink
Update PIXELVALVE2 address for RPI4
Browse files Browse the repository at this point in the history
  • Loading branch information
IanSB committed Apr 19, 2021
1 parent 3313630 commit 63b3375
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/defs.h
Expand Up @@ -386,10 +386,18 @@ typedef struct {

#define SCALER_BASE (volatile uint32_t *)(PERIPHERAL_BASE + 0x400000)


#if defined(RPI4)
#define PIXELVALVE2_HORZA (volatile uint32_t *)(PERIPHERAL_BASE + 0x20a00c)
#define PIXELVALVE2_HORZB (volatile uint32_t *)(PERIPHERAL_BASE + 0x20a010)
#define PIXELVALVE2_VERTA (volatile uint32_t *)(PERIPHERAL_BASE + 0x20a014)
#define PIXELVALVE2_VERTB (volatile uint32_t *)(PERIPHERAL_BASE + 0x20a018)
#else
#define PIXELVALVE2_HORZA (volatile uint32_t *)(PERIPHERAL_BASE + 0x80700c)
#define PIXELVALVE2_HORZB (volatile uint32_t *)(PERIPHERAL_BASE + 0x807010)
#define PIXELVALVE2_VERTA (volatile uint32_t *)(PERIPHERAL_BASE + 0x807014)
#define PIXELVALVE2_VERTB (volatile uint32_t *)(PERIPHERAL_BASE + 0x807018)
#endif

#define PM_RSTC (volatile uint32_t *)(PERIPHERAL_BASE + 0x10001c)
#define PM_WDOG (volatile uint32_t *)(PERIPHERAL_BASE + 0x100024)
Expand Down
8 changes: 2 additions & 6 deletions src/geometry.c
Expand Up @@ -880,9 +880,10 @@ int get_vaspect() {

int get_hdisplay() {
#if defined(RPI4)
int h_size = 1920;
int h_size = ((*PIXELVALVE2_HORZB) & 0xFFFF) << 1;
#else
int h_size = (*PIXELVALVE2_HORZB) & 0xFFFF;
#endif
int v_size = (*PIXELVALVE2_VERTB) & 0xFFFF;
int l;
int r;
Expand All @@ -903,7 +904,6 @@ int get_hdisplay() {
}
get_config_overscan(&l, &r, &t, &b);
h_size = h_size - l - r;
#endif
return h_size;
}

Expand All @@ -912,11 +912,7 @@ int get_vdisplay() {
int r;
int t;
int b;
#if defined(RPI4)
int v_size = 1080;
#else
int v_size = (*PIXELVALVE2_VERTB) & 0xFFFF;
#endif
get_config_overscan(&l, &r, &t, &b);
v_size = v_size - t - b;
return v_size;
Expand Down
2 changes: 1 addition & 1 deletion src/rgb_to_hdmi.c
Expand Up @@ -995,7 +995,7 @@ static void recalculate_hdmi_clock(int vlockmode, int genlock_adjust) {
// A[15: 0] - synch width in pixels
// B[31:16] - front porch width in pixels
// B[15: 0] - active line width in pixels
uint32_t htotal = (*PIXELVALVE2_HORZA) + (*PIXELVALVE2_HORZB);
uint32_t htotal = (*PIXELVALVE2_HORZA) + (*PIXELVALVE2_HORZB); //PI4: needs fixing (<<1)
htotal = (htotal + (htotal >> 16)) & 0xFFFF;
uint32_t vtotal = (*PIXELVALVE2_VERTA) + (*PIXELVALVE2_VERTB);
vtotal = (vtotal + (vtotal >> 16)) & 0xFFFF;
Expand Down

0 comments on commit 63b3375

Please sign in to comment.