Skip to content
Snippets Groups Projects
drm_crtc_helper.c 28.6 KiB
Newer Older
  • Learn to ignore specific revisions
  • 	if (mode == connector->dpms)
    		return;
    
    	old_dpms = connector->dpms;
    	connector->dpms = mode;
    
    	/* from off to on, do crtc then encoder */
    	if (mode < old_dpms) {
    		if (crtc) {
    			struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
    			if (crtc_funcs->dpms)
    				(*crtc_funcs->dpms) (crtc,
    						     drm_helper_choose_crtc_dpms(crtc));
    		}
    		if (encoder) {
    			struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
    			if (encoder_funcs->dpms)
    				(*encoder_funcs->dpms) (encoder,
    							drm_helper_choose_encoder_dpms(encoder));
    		}
    	}
    
    	/* from on to off, do encoder then crtc */
    	if (mode > old_dpms) {
    		if (encoder) {
    			struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
    			if (encoder_funcs->dpms)
    				(*encoder_funcs->dpms) (encoder,
    							drm_helper_choose_encoder_dpms(encoder));
    		}
    		if (crtc) {
    			struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
    			if (crtc_funcs->dpms)
    				(*crtc_funcs->dpms) (crtc,
    						     drm_helper_choose_crtc_dpms(crtc));
    		}
    	}
    
    	return;
    }
    EXPORT_SYMBOL(drm_helper_connector_dpms);
    
    
    /**
     * drm_hotplug_stage_two
     * @dev DRM device
     * @connector hotpluged connector
     *
     * LOCKING.
     * Caller must hold mode config lock, function might grab struct lock.
     *
     * Stage two of a hotplug.
     *
     * RETURNS:
     * Zero on success, errno on failure.
     */
    int drm_helper_hotplug_stage_two(struct drm_device *dev)
    {
    	drm_helper_plugged_event(dev);
    
    	return 0;
    }
    EXPORT_SYMBOL(drm_helper_hotplug_stage_two);
    
    int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
    				   struct drm_mode_fb_cmd *mode_cmd)
    {
    	fb->width = mode_cmd->width;
    	fb->height = mode_cmd->height;
    	fb->pitch = mode_cmd->pitch;
    	fb->bits_per_pixel = mode_cmd->bpp;
    	fb->depth = mode_cmd->depth;
    
    	return 0;
    }
    EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct);
    
    int drm_helper_resume_force_mode(struct drm_device *dev)
    {
    	struct drm_crtc *crtc;
    	int ret;
    
    	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
    
    		if (!crtc->enabled)
    			continue;
    
    
    		ret = drm_crtc_helper_set_mode(crtc, &crtc->mode,
    					       crtc->x, crtc->y, crtc->fb);
    
    
    		if (ret == false)
    			DRM_ERROR("failed to set mode on crtc %p\n", crtc);
    	}
    
    	/* disable the unused connectors while restoring the modesetting */
    	drm_helper_disable_unused_functions(dev);
    
    	return 0;
    }
    EXPORT_SYMBOL(drm_helper_resume_force_mode);