749N/A/*
749N/A * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
749N/A */
749N/A
749N/A/*
749N/A * Copyright © 2006 Keith Packard
749N/A * Copyright © 2007-2008 Dave Airlie
749N/A * Copyright (c) 2007-2008, 2013, Intel Corporation
749N/A * Jesse Barnes <jesse.barnes@intel.com>
749N/A *
749N/A * Permission is hereby granted, free of charge, to any person obtaining a
749N/A * copy of this software and associated documentation files (the "Software"),
749N/A * to deal in the Software without restriction, including without limitation
749N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
749N/A * and/or sell copies of the Software, and to permit persons to whom the
749N/A * Software is furnished to do so, subject to the following conditions:
749N/A *
749N/A * The above copyright notice and this permission notice shall be included in
749N/A * all copies or substantial portions of the Software.
749N/A *
749N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
749N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
749N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
749N/A * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
749N/A * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
749N/A * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
749N/A * OTHER DEALINGS IN THE SOFTWARE.
749N/A */
749N/A
749N/A/*
749N/A * The DRM mode setting helper functions are common code for drivers to use if
749N/A * they wish. Drivers are not forced to use this code in their
749N/A * implementations but it would be useful if they code they do use at least
749N/A * provides a consistent interface and operation to userspace
749N/A */
749N/A
749N/A#ifndef __DRM_CRTC_HELPER_H__
749N/A#define __DRM_CRTC_HELPER_H__
749N/A
749N/A#include <sys/types.h>
749N/A#include "drmP.h"
749N/A#include "drm_sun_idr.h"
749N/A
749N/Aenum mode_set_atomic {
749N/A LEAVE_ATOMIC_MODE_SET,
749N/A ENTER_ATOMIC_MODE_SET,
749N/A};
749N/A
749N/A/**
749N/A * drm_crtc_helper_funcs - helper operations for CRTCs
749N/A * @mode_fixup: try to fixup proposed mode for this connector
749N/A * @mode_set: set this mode
749N/A *
749N/A * The helper operations are called by the mid-layer CRTC helper.
749N/A */
749N/Astruct drm_crtc_helper_funcs {
749N/A /*
749N/A * Control power levels on the CRTC. If the mode passed in is
749N/A * unsupported, the provider must use the next lowest power level.
749N/A */
749N/A void (*dpms)(struct drm_crtc *crtc, int mode);
749N/A void (*prepare)(struct drm_crtc *crtc);
749N/A void (*commit)(struct drm_crtc *crtc);
749N/A
749N/A /* Provider can fixup or change mode timings before modeset occurs */
749N/A bool (*mode_fixup)(struct drm_crtc *crtc,
749N/A const struct drm_display_mode *mode,
749N/A struct drm_display_mode *adjusted_mode);
749N/A /* Actually set the mode */
749N/A int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
749N/A struct drm_display_mode *adjusted_mode, int x, int y,
749N/A struct drm_framebuffer *old_fb);
749N/A
749N/A /* Move the crtc on the current fb to the given position *optional* */
749N/A int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
749N/A struct drm_framebuffer *old_fb);
749N/A int (*mode_set_base_atomic)(struct drm_crtc *crtc,
749N/A struct drm_framebuffer *fb, int x, int y,
749N/A enum mode_set_atomic);
749N/A
749N/A /* reload the current crtc LUT */
749N/A void (*load_lut)(struct drm_crtc *crtc);
749N/A
749N/A /* disable crtc when not in use - more explicit than dpms off */
749N/A void (*disable)(struct drm_crtc *crtc);
749N/A};
749N/A
749N/A/**
749N/A * drm_encoder_helper_funcs - helper operations for encoders
749N/A * @mode_fixup: try to fixup proposed mode for this connector
749N/A * @mode_set: set this mode
749N/A *
749N/A * The helper operations are called by the mid-layer CRTC helper.
749N/A */
749N/Astruct drm_encoder_helper_funcs {
749N/A void (*dpms)(struct drm_encoder *encoder, int mode);
749N/A void (*save)(struct drm_encoder *encoder);
749N/A void (*restore)(struct drm_encoder *encoder);
749N/A
749N/A bool (*mode_fixup)(struct drm_encoder *encoder,
749N/A const struct drm_display_mode *mode,
749N/A struct drm_display_mode *adjusted_mode);
749N/A void (*prepare)(struct drm_encoder *encoder);
749N/A void (*commit)(struct drm_encoder *encoder);
749N/A void (*mode_set)(struct drm_encoder *encoder,
749N/A struct drm_display_mode *mode,
749N/A struct drm_display_mode *adjusted_mode);
749N/A struct drm_crtc *(*get_crtc)(struct drm_encoder *encoder);
749N/A /* detect for DAC style encoders */
749N/A enum drm_connector_status (*detect)(struct drm_encoder *encoder,
749N/A struct drm_connector *connector);
749N/A /* disable encoder when not in use - more explicit than dpms off */
749N/A void (*disable)(struct drm_encoder *encoder);
749N/A};
749N/A
749N/A/**
749N/A * drm_connector_helper_funcs - helper operations for connectors
749N/A * @get_modes: get mode list for this connector
749N/A * @mode_valid: is this mode valid on the given connector?
749N/A *
749N/A * The helper operations are called by the mid-layer CRTC helper.
749N/A */
749N/Astruct drm_connector_helper_funcs {
749N/A int (*get_modes)(struct drm_connector *connector);
749N/A int (*mode_valid)(struct drm_connector *connector,
749N/A struct drm_display_mode *mode);
749N/A struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
749N/A};
749N/A
749N/Aextern int drm_helper_probe_single_connector_modes(struct drm_connector *connector, uint32_t maxX, uint32_t maxY);
749N/Aextern void drm_helper_disable_unused_functions(struct drm_device *dev);
749N/Aextern int drm_crtc_helper_set_config(struct drm_mode_set *set);
749N/Aextern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
749N/A struct drm_display_mode *mode,
749N/A int x, int y,
749N/A struct drm_framebuffer *old_fb);
749N/Aextern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
749N/Aextern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
749N/A
749N/Aextern void drm_helper_connector_dpms(struct drm_connector *connector, int mode);
749N/A
749N/Aextern void drm_helper_move_panel_connectors_to_head(struct drm_device *);
749N/A
749N/Aextern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
749N/A struct drm_mode_fb_cmd2 *mode_cmd);
749N/A
749N/Astatic inline void drm_crtc_helper_add(struct drm_crtc *crtc,
749N/A const struct drm_crtc_helper_funcs *funcs)
749N/A{
749N/A crtc->helper_private = (void *)funcs;
749N/A}
749N/A
749N/Astatic inline void drm_encoder_helper_add(struct drm_encoder *encoder,
749N/A const struct drm_encoder_helper_funcs *funcs)
749N/A{
749N/A encoder->helper_private = (void *)funcs;
749N/A}
749N/A
749N/Astatic inline void drm_connector_helper_add(struct drm_connector *connector,
749N/A const struct drm_connector_helper_funcs *funcs)
749N/A{
749N/A connector->helper_private = (void *)funcs;
749N/A}
749N/A
749N/Aextern void drm_helper_resume_force_mode(struct drm_device *dev);
749N/Aextern void drm_kms_helper_poll_init(struct drm_device *dev);
749N/Aextern void drm_kms_helper_poll_fini(struct drm_device *dev);
749N/Aextern void drm_helper_hpd_irq_event(struct drm_device *dev);
749N/Aextern void drm_kms_helper_hotplug_event(struct drm_device *dev);
749N/A
749N/Aextern void drm_kms_helper_poll_disable(struct drm_device *dev);
749N/Aextern void drm_kms_helper_poll_enable(struct drm_device *dev);
749N/A
749N/A#endif /* __DRM_CRTC_HELPER_H__ */
749N/A