diff mbox series

[108/120] MIPS: PS2: FB: fb_blank() display power management signaling (DPMS)

Message ID 2ac54422f1a639be35b049f1608e0f5f7d3e19dd.1567326213.git.noring@nocrew.org (mailing list archive)
State RFC
Headers show
Series Linux for the PlayStation 2 | expand

Commit Message

Fredrik Noring Sept. 1, 2019, 4:34 p.m. UTC
The Graphics Synthesizer implements four DPMS levels: on, standby,
suspend and off. The level is set with the SMODE2 register DPMS
field[1].

References:

[1] "GS User's Manual", version 6.0, Sony Computer Entertainment Inc.,
    p. 157.

Signed-off-by: Fredrik Noring <noring@nocrew.org>
---
 drivers/video/fbdev/ps2fb.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
diff mbox series

Patch

diff --git a/drivers/video/fbdev/ps2fb.c b/drivers/video/fbdev/ps2fb.c
index 73fc1fd3f4eb..92957797045f 100644
--- a/drivers/video/fbdev/ps2fb.c
+++ b/drivers/video/fbdev/ps2fb.c
@@ -2004,6 +2004,38 @@  static int ps2fb_cb_set_par(struct fb_info *info)
 	return err;
 }
 
+/**
+ * ps2fb_blank - VESA display power management signaling (DPMS)
+ * @blank: frame buffer blanking level
+ * @info: frame buffer info object
+ *
+ * Return: 0 on success, otherwise a negative error number
+ */
+static int ps2fb_blank(int blank, struct fb_info *info)
+{
+	struct ps2fb_par *par = info->par;
+	struct gs_smode2 smode2;
+	unsigned long flags;
+
+	if (!gs_valid_smode2())
+		return -EIO;	/* Blanking before video mode is set. */
+
+	spin_lock_irqsave(&par->lock, flags);
+
+	smode2 = gs_read_smode2();
+
+	smode2.dpms = blank == FB_BLANK_POWERDOWN     ? gs_dpms_off :
+		      blank == FB_BLANK_NORMAL        ? gs_dpms_standby :
+		      blank == FB_BLANK_VSYNC_SUSPEND ? gs_dpms_suspend :
+		      blank == FB_BLANK_HSYNC_SUSPEND ? gs_dpms_suspend :
+							gs_dpms_on;
+	gs_write_smode2(smode2);
+
+	spin_unlock_irqrestore(&par->lock, flags);
+
+	return 0;
+}
+
 static u32 block_dimensions(u32 dim, u32 alignment)
 {
 	u32 mask = 0;
@@ -2032,6 +2064,7 @@  static int init_console_buffer(struct platform_device *pdev,
 {
 	static struct fb_ops fbops = {
 		.owner		= THIS_MODULE,
+		.fb_blank	= ps2fb_blank,
 		.fb_setcolreg	= ps2fb_setcolreg,
 		.fb_set_par	= ps2fb_cb_set_par,
 		.fb_check_var	= ps2fb_cb_check_var,