Skip to content

Commit 53e82b4

Browse files
6by9popcornmix
authored andcommitted
drm: vc4: Add status of which display is updated through vblank
Previously multiple displays were slaved off the same SMI interrupt, triggered by HVS channel 1 (HDMI0). This doesn't work if you only have a DPI or DSI screen (HVS channel 0), and gives slightly erroneous results with dual HDMI as the events for HDMI1 are incorrect. Use SMIDSW0 and SMIDSW1 registers to denote which display has triggered the vblank. Handling should be backwards compatible with older firmware. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
1 parent baa1898 commit 53e82b4

1 file changed

Lines changed: 36 additions & 5 deletions

File tree

‎drivers/gpu/drm/vc4/vc4_firmware_kms.c‎

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,13 @@ static const struct vc_image_format *vc4_get_vc_image_fmt(u32 drm_format)
231231
* hardware, which has only this one register.
232232
*/
233233
#define SMICS 0x0
234+
#define SMIDSW0 0x14
235+
#define SMIDSW1 0x1C
234236
#define SMICS_INTERRUPTS (BIT(9) | BIT(10) | BIT(11))
235237

238+
/* Flag to denote that the firmware is giving multiple display callbacks */
239+
#define SMI_NEW 0xabcd0000
240+
236241
#define vc4_crtc vc4_kms_crtc
237242
#define to_vc4_crtc to_vc4_kms_crtc
238243
struct vc4_crtc {
@@ -883,16 +888,42 @@ static irqreturn_t vc4_crtc_irq_handler(int irq, void *data)
883888
int i;
884889
u32 stat = readl(crtc_list[0]->regs + SMICS);
885890
irqreturn_t ret = IRQ_NONE;
891+
u32 chan;
886892

887893
if (stat & SMICS_INTERRUPTS) {
888894
writel(0, crtc_list[0]->regs + SMICS);
889895

890-
for (i = 0; crtc_list[i]; i++) {
891-
if (crtc_list[i]->vblank_enabled)
892-
drm_crtc_handle_vblank(&crtc_list[i]->base);
893-
vc4_crtc_handle_page_flip(crtc_list[i]);
894-
ret = IRQ_HANDLED;
896+
chan = readl(crtc_list[0]->regs + SMIDSW0);
897+
898+
if ((chan & 0xFFFF0000) != SMI_NEW) {
899+
/* Older firmware. Treat the one interrupt as vblank/
900+
* complete for all crtcs.
901+
*/
902+
for (i = 0; crtc_list[i]; i++) {
903+
if (crtc_list[i]->vblank_enabled)
904+
drm_crtc_handle_vblank(&crtc_list[i]->base);
905+
vc4_crtc_handle_page_flip(crtc_list[i]);
906+
}
907+
} else {
908+
if (chan & 1) {
909+
writel(SMI_NEW, crtc_list[0]->regs + SMIDSW0);
910+
if (crtc_list[0]->vblank_enabled)
911+
drm_crtc_handle_vblank(&crtc_list[0]->base);
912+
vc4_crtc_handle_page_flip(crtc_list[0]);
913+
}
914+
915+
/* Check for the secondary display too */
916+
chan = readl(crtc_list[0]->regs + SMIDSW1);
917+
918+
if (chan & 1) {
919+
writel(SMI_NEW, crtc_list[0]->regs + SMIDSW1);
920+
if (crtc_list[1]->vblank_enabled)
921+
drm_crtc_handle_vblank(&crtc_list[1]->base);
922+
vc4_crtc_handle_page_flip(crtc_list[1]);
923+
}
895924
}
925+
926+
ret = IRQ_HANDLED;
896927
}
897928

898929
return ret;

0 commit comments

Comments
 (0)