Commit 997d33c3 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/udl: Inline DPMS code into CRTC enable and disable functions

DPMS functionality is only used by the CRTC's enable and disable
functions. Inline the code. The patch also adds symbolic constants
for the blank register and constants; according to udlfb, which is
a bit more detailed than DRM's udl.

v3:
	* use symbolic constants for blank, according to udlfb driver
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarEmil Velikov <emil.l.velikov@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191210084905.5570-5-tzimmermann@suse.de
parent ae08b88a
...@@ -110,4 +110,13 @@ int udl_drop_usb(struct drm_device *dev); ...@@ -110,4 +110,13 @@ int udl_drop_usb(struct drm_device *dev);
#define CMD_WRITE_COPY16 "\xAF\x6A" /**< 16 bit copy command. */ #define CMD_WRITE_COPY16 "\xAF\x6A" /**< 16 bit copy command. */
#define CMD_WRITE_RLX16 "\xAF\x6B" /**< 16 bit extended run length command. */ #define CMD_WRITE_RLX16 "\xAF\x6B" /**< 16 bit extended run length command. */
/* On/Off for driving the DisplayLink framebuffer to the display */
#define UDL_REG_BLANK_MODE 0x1f
#define UDL_BLANK_MODE_ON 0x00 /* hsync and vsync on, visible */
#define UDL_BLANK_MODE_BLANKED 0x01 /* hsync and vsync on, blanked */
#define UDL_BLANK_MODE_VSYNC_OFF 0x03 /* vsync off, blanked */
#define UDL_BLANK_MODE_HSYNC_OFF 0x05 /* hsync off, blanked */
#define UDL_BLANK_MODE_POWERDOWN 0x07 /* powered off; requires modeset */
#endif #endif
...@@ -42,31 +42,9 @@ static char *udl_vidreg_unlock(char *buf) ...@@ -42,31 +42,9 @@ static char *udl_vidreg_unlock(char *buf)
return udl_set_register(buf, 0xFF, 0xFF); return udl_set_register(buf, 0xFF, 0xFF);
} }
/* static char *udl_set_blank_mode(char *buf, u8 mode)
* On/Off for driving the DisplayLink framebuffer to the display
* 0x00 H and V sync on
* 0x01 H and V sync off (screen blank but powered)
* 0x07 DPMS powerdown (requires modeset to come back)
*/
static char *udl_set_blank(char *buf, int dpms_mode)
{ {
u8 reg; return udl_set_register(buf, UDL_REG_BLANK_MODE, mode);
switch (dpms_mode) {
case DRM_MODE_DPMS_OFF:
reg = 0x07;
break;
case DRM_MODE_DPMS_STANDBY:
reg = 0x05;
break;
case DRM_MODE_DPMS_SUSPEND:
reg = 0x01;
break;
case DRM_MODE_DPMS_ON:
reg = 0x00;
break;
}
return udl_set_register(buf, 0x1f, reg);
} }
static char *udl_set_color_depth(char *buf, u8 selection) static char *udl_set_color_depth(char *buf, u8 selection)
...@@ -237,6 +215,11 @@ static int udl_crtc_write_mode_to_hw(struct drm_crtc *crtc) ...@@ -237,6 +215,11 @@ static int udl_crtc_write_mode_to_hw(struct drm_crtc *crtc)
char *buf; char *buf;
int retval; int retval;
if (udl->mode_buf_len == 0) {
DRM_ERROR("No mode set\n");
return -EINVAL;
}
urb = udl_get_urb(dev); urb = udl_get_urb(dev);
if (!urb) if (!urb)
return -ENOMEM; return -ENOMEM;
...@@ -249,38 +232,6 @@ static int udl_crtc_write_mode_to_hw(struct drm_crtc *crtc) ...@@ -249,38 +232,6 @@ static int udl_crtc_write_mode_to_hw(struct drm_crtc *crtc)
return retval; return retval;
} }
static void udl_crtc_dpms(struct drm_crtc *crtc, int mode)
{
struct drm_device *dev = crtc->dev;
struct udl_device *udl = dev->dev_private;
int retval;
if (mode == DRM_MODE_DPMS_OFF) {
char *buf;
struct urb *urb;
urb = udl_get_urb(dev);
if (!urb)
return;
buf = (char *)urb->transfer_buffer;
buf = udl_vidreg_lock(buf);
buf = udl_set_blank(buf, mode);
buf = udl_vidreg_unlock(buf);
buf = udl_dummy_render(buf);
retval = udl_submit_urb(dev, urb, buf - (char *)
urb->transfer_buffer);
} else {
if (udl->mode_buf_len == 0) {
DRM_ERROR("Trying to enable DPMS with no mode\n");
return;
}
udl_crtc_write_mode_to_hw(crtc);
}
}
/* /*
* Simple display pipeline * Simple display pipeline
*/ */
...@@ -327,7 +278,7 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, ...@@ -327,7 +278,7 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
wrptr = udl_set_base8bpp(wrptr, 2 * mode->vdisplay * mode->hdisplay); wrptr = udl_set_base8bpp(wrptr, 2 * mode->vdisplay * mode->hdisplay);
wrptr = udl_set_vid_cmds(wrptr, mode); wrptr = udl_set_vid_cmds(wrptr, mode);
wrptr = udl_set_blank(wrptr, DRM_MODE_DPMS_ON); wrptr = udl_set_blank_mode(wrptr, UDL_BLANK_MODE_ON);
wrptr = udl_vidreg_unlock(wrptr); wrptr = udl_vidreg_unlock(wrptr);
wrptr = udl_dummy_render(wrptr); wrptr = udl_dummy_render(wrptr);
...@@ -339,13 +290,32 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, ...@@ -339,13 +290,32 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe,
udl_handle_damage(fb, 0, 0, fb->width, fb->height); udl_handle_damage(fb, 0, 0, fb->width, fb->height);
udl_crtc_dpms(&pipe->crtc, DRM_MODE_DPMS_ON); if (!crtc_state->mode_changed)
return;
/* enable display */
udl_crtc_write_mode_to_hw(crtc);
} }
static void static void
udl_simple_display_pipe_disable(struct drm_simple_display_pipe *pipe) udl_simple_display_pipe_disable(struct drm_simple_display_pipe *pipe)
{ {
udl_crtc_dpms(&pipe->crtc, DRM_MODE_DPMS_OFF); struct drm_crtc *crtc = &pipe->crtc;
struct drm_device *dev = crtc->dev;
struct urb *urb;
char *buf;
urb = udl_get_urb(dev);
if (!urb)
return;
buf = (char *)urb->transfer_buffer;
buf = udl_vidreg_lock(buf);
buf = udl_set_blank_mode(buf, UDL_BLANK_MODE_POWERDOWN);
buf = udl_vidreg_unlock(buf);
buf = udl_dummy_render(buf);
udl_submit_urb(dev, urb, buf - (char *)urb->transfer_buffer);
} }
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment