Hi Am 21.04.21 um 10:08 schrieb Takashi Iwai: > On bochs DRM driver, the execution of "setterm --blank force" results > in a frozen screen instead of a blank screen. It's due to the lack of > the screen blanking support in its code. > > Actually, the QEMU bochs vga side can switch to the blanking mode when > the bit 0x20 is cleared on VGA_ATT_IW register (0x3c0), which updates > ar_index in QEMU side. So, essentially, we'd just need to clear the > bit at pipe disable callback; that's what this patch does essentially. > > However, a tricky part is that the access via VGA_ATT_IW is done in > "flip-flop"; the first write is for index and the second write is for > the data like palette. Meanwhile, in the current bochs DRM driver, > the flip-flop wasn't considered, and it calls only the register update > once with the value 0x20. I read up on the details of what the attribute registers do and what you're modifying is the PAS field in the attribute index register. It controls write access to the attribute fields. https://web.stanford.edu/class/cs140/projects/pintos/specs/freevga/vga/attrreg.htm#3C0 It's located in the index register and cleared while attributes/palettes are updated. I guess that in this mode the stdvga disables the palette entirely (hence the screen turns dark). While it works, it feels wrong to do this. I to do blanking/unblanking with the SR field in SEQ0 https://web.stanford.edu/class/cs140/projects/pintos/specs/freevga/vga/seqreg.htm#00 That's what drivers usually do AFAICT. I think the 'unblank' comment next to the existing code might be misleading. Best regards Thomas > > The spec and the actual VGA implementation in QEMU suggests that the > flip flop flag is discarded by reading the CRTC index register > (VGA_IS1_RC, 0x3da). So, in this patch, we add the helper to read a > byte and the call to clear the flip flop flag before changing the > blank / unblank setup via VGA_ATT_IW register. > > v1->v2: > * discard ar_flip_flop by reading 0x3da, add bochs_vga_readb() > * include video/vga.h for VGA register definitions > * move the blank/unblank code to bochs_hw_blank() > > Signed-off-by: Takashi Iwai > --- > drivers/gpu/drm/bochs/bochs.h | 1 + > drivers/gpu/drm/bochs/bochs_hw.c | 25 ++++++++++++++++++++++++- > drivers/gpu/drm/bochs/bochs_kms.c | 8 ++++++++ > 3 files changed, 33 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h > index e5bd1d517a18..e9645c612aff 100644 > --- a/drivers/gpu/drm/bochs/bochs.h > +++ b/drivers/gpu/drm/bochs/bochs.h > @@ -78,6 +78,7 @@ struct bochs_device { > int bochs_hw_init(struct drm_device *dev); > void bochs_hw_fini(struct drm_device *dev); > > +void bochs_hw_blank(struct bochs_device *bochs, bool blank); > void bochs_hw_setmode(struct bochs_device *bochs, > struct drm_display_mode *mode); > void bochs_hw_setformat(struct bochs_device *bochs, > diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs/bochs_hw.c > index 2d7380a9890e..7d3426d8cc69 100644 > --- a/drivers/gpu/drm/bochs/bochs_hw.c > +++ b/drivers/gpu/drm/bochs/bochs_hw.c > @@ -7,6 +7,7 @@ > #include > #include > > +#include