From a05c7d795ddd9b349fea33e8ca28d9fba3936176 Mon Sep 17 00:00:00 2001 From: Tony Kuker Date: Sun, 16 Jan 2022 20:13:01 +0000 Subject: [PATCH] Blank flashing cursor when powerview is enabled --- src/raspberrypi/devices/scsi_powerview.cpp | 45 +++++++++++++++++++--- src/raspberrypi/devices/scsi_powerview.h | 3 ++ 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/raspberrypi/devices/scsi_powerview.cpp b/src/raspberrypi/devices/scsi_powerview.cpp index 8c9756bc..6fcf8699 100644 --- a/src/raspberrypi/devices/scsi_powerview.cpp +++ b/src/raspberrypi/devices/scsi_powerview.cpp @@ -106,17 +106,52 @@ SCSIPowerView::SCSIPowerView() : Disk("SCPV") this->m_powerview_resolution_x = 624; this->m_powerview_resolution_y = 840; + fbcon_cursor(false); + fbcon_blank(false); ClearFrameBuffer(); } +//--------------------------------------------------------------------------- +// +// Enable/Disable the framebuffer flashing cursor +// From: https://linux-arm-kernel.infradead.narkive.com/XL0ylAHW/turn-off-framebuffer-cursor +// +//--------------------------------------------------------------------------- +void SCSIPowerView::fbcon_cursor(bool blank) +{ + int fd = open("/dev/tty1", O_RDWR); + if (0 < fd) + { + write(fd, "\033[?25", 5); + write(fd, blank ? "h" : "l", 1); + } + else + { + LOGWARN("%s Unable to open /dev/tty1", __PRETTY_FUNCTION__); + } + close(fd); +} + +//--------------------------------------------------------------------------- +// +// Enable/disable the framebuffer blanking +// From: https://linux-arm-kernel.infradead.narkive.com/XL0ylAHW/turn-off-framebuffer-cursor +// +//--------------------------------------------------------------------------- +void SCSIPowerView::fbcon_blank(bool blank) +{ + int ret = ioctl(fbfd, FBIOBLANK, blank ? VESA_POWERDOWN : VESA_NO_BLANKING); + if(ret < 0){ + LOGWARN("%s Unable to disable blanking", __PRETTY_FUNCTION__); + } + return; +} + SCSIPowerView::~SCSIPowerView() { - // // TAP driver release - // if (m_tap) { - // m_tap->Cleanup(); - // delete m_tap; - // } + // Re-enable the cursor + fbcon_cursor(true); munmap(this->fb, this->fbsize); close(this->fbfd); diff --git a/src/raspberrypi/devices/scsi_powerview.h b/src/raspberrypi/devices/scsi_powerview.h index 0dfb6f8e..940c2355 100644 --- a/src/raspberrypi/devices/scsi_powerview.h +++ b/src/raspberrypi/devices/scsi_powerview.h @@ -55,6 +55,9 @@ private: DWORD m_powerview_resolution_x; DWORD m_powerview_resolution_y; + void fbcon_cursor(bool blank); + void fbcon_blank(bool blank); + public: SCSIPowerView(); ~SCSIPowerView();