Commit 8bd441b2 authored by Daniel Vetter's avatar Daniel Vetter

drm: move drm_mode related functions into drm_modes.c

Makes more sense and gives better grouping in the DocBook function
reference sections. To make this possible we need to expose two
functions from drm_crtc.c though. To avoid further namespace pollution
in the system wide headers create a new internal header for such drm
internal symbols.

I expect that longer-term we'll add tons more, but since my goal here
is to polish the kerneldoc that's for another day.
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 63951385
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include <drm/drm_edid.h> #include <drm/drm_edid.h>
#include <drm/drm_fourcc.h> #include <drm/drm_fourcc.h>
#include "drm_crtc_internal.h"
/** /**
* drm_modeset_lock_all - take all modeset locks * drm_modeset_lock_all - take all modeset locks
* @dev: drm device * @dev: drm device
...@@ -322,8 +324,8 @@ EXPORT_SYMBOL(drm_get_format_name); ...@@ -322,8 +324,8 @@ EXPORT_SYMBOL(drm_get_format_name);
* New unique (relative to other objects in @dev) integer identifier for the * New unique (relative to other objects in @dev) integer identifier for the
* object. * object.
*/ */
static int drm_mode_object_get(struct drm_device *dev, int drm_mode_object_get(struct drm_device *dev,
struct drm_mode_object *obj, uint32_t obj_type) struct drm_mode_object *obj, uint32_t obj_type)
{ {
int ret; int ret;
...@@ -349,8 +351,8 @@ static int drm_mode_object_get(struct drm_device *dev, ...@@ -349,8 +351,8 @@ static int drm_mode_object_get(struct drm_device *dev,
* *
* Free @id from @dev's unique identifier pool. * Free @id from @dev's unique identifier pool.
*/ */
static void drm_mode_object_put(struct drm_device *dev, void drm_mode_object_put(struct drm_device *dev,
struct drm_mode_object *object) struct drm_mode_object *object)
{ {
mutex_lock(&dev->mode_config.idr_mutex); mutex_lock(&dev->mode_config.idr_mutex);
idr_remove(&dev->mode_config.crtc_idr, object->id); idr_remove(&dev->mode_config.crtc_idr, object->id);
...@@ -720,22 +722,6 @@ unsigned int drm_crtc_index(struct drm_crtc *crtc) ...@@ -720,22 +722,6 @@ unsigned int drm_crtc_index(struct drm_crtc *crtc)
} }
EXPORT_SYMBOL(drm_crtc_index); EXPORT_SYMBOL(drm_crtc_index);
/**
* drm_mode_probed_add - add a mode to a connector's probed mode list
* @connector: connector the new mode
* @mode: mode data
*
* Add @mode to @connector's mode list for later use.
*/
void drm_mode_probed_add(struct drm_connector *connector,
struct drm_display_mode *mode)
{
WARN_ON(!mutex_is_locked(&connector->dev->mode_config.mutex));
list_add_tail(&mode->head, &connector->probed_modes);
}
EXPORT_SYMBOL(drm_mode_probed_add);
/* /*
* drm_mode_remove - remove and free a mode * drm_mode_remove - remove and free a mode
* @connector: connector list to modify * @connector: connector list to modify
...@@ -1035,50 +1021,6 @@ void drm_plane_force_disable(struct drm_plane *plane) ...@@ -1035,50 +1021,6 @@ void drm_plane_force_disable(struct drm_plane *plane)
} }
EXPORT_SYMBOL(drm_plane_force_disable); EXPORT_SYMBOL(drm_plane_force_disable);
/**
* drm_mode_create - create a new display mode
* @dev: DRM device
*
* Create a new drm_display_mode, give it an ID, and return it.
*
* RETURNS:
* Pointer to new mode on success, NULL on error.
*/
struct drm_display_mode *drm_mode_create(struct drm_device *dev)
{
struct drm_display_mode *nmode;
nmode = kzalloc(sizeof(struct drm_display_mode), GFP_KERNEL);
if (!nmode)
return NULL;
if (drm_mode_object_get(dev, &nmode->base, DRM_MODE_OBJECT_MODE)) {
kfree(nmode);
return NULL;
}
return nmode;
}
EXPORT_SYMBOL(drm_mode_create);
/**
* drm_mode_destroy - remove a mode
* @dev: DRM device
* @mode: mode to remove
*
* Free @mode's unique identifier, then free it.
*/
void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode)
{
if (!mode)
return;
drm_mode_object_put(dev, &mode->base);
kfree(mode);
}
EXPORT_SYMBOL(drm_mode_destroy);
static int drm_mode_create_standard_connector_properties(struct drm_device *dev) static int drm_mode_create_standard_connector_properties(struct drm_device *dev)
{ {
struct drm_property *edid; struct drm_property *edid;
......
/*
* Copyright © 2006 Keith Packard
* Copyright © 2007-2008 Dave Airlie
* Copyright © 2007-2008 Intel Corporation
* Jesse Barnes <jesse.barnes@intel.com>
* Copyright © 2014 Intel Corporation
* Daniel Vetter <daniel.vetter@ffwll.ch>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* This header file contains mode setting related functions and definitions
* which are only used within the drm module as internal implementation details
* and are not exported to drivers.
*/
int drm_mode_object_get(struct drm_device *dev,
struct drm_mode_object *obj, uint32_t obj_type);
void drm_mode_object_put(struct drm_device *dev,
struct drm_mode_object *object);
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include <video/of_videomode.h> #include <video/of_videomode.h>
#include <video/videomode.h> #include <video/videomode.h>
#include "drm_crtc_internal.h"
/** /**
* drm_mode_debug_printmodeline - print a mode to dmesg * drm_mode_debug_printmodeline - print a mode to dmesg
* @mode: mode to print * @mode: mode to print
...@@ -56,6 +58,66 @@ void drm_mode_debug_printmodeline(const struct drm_display_mode *mode) ...@@ -56,6 +58,66 @@ void drm_mode_debug_printmodeline(const struct drm_display_mode *mode)
} }
EXPORT_SYMBOL(drm_mode_debug_printmodeline); EXPORT_SYMBOL(drm_mode_debug_printmodeline);
/**
* drm_mode_create - create a new display mode
* @dev: DRM device
*
* Create a new drm_display_mode, give it an ID, and return it.
*
* RETURNS:
* Pointer to new mode on success, NULL on error.
*/
struct drm_display_mode *drm_mode_create(struct drm_device *dev)
{
struct drm_display_mode *nmode;
nmode = kzalloc(sizeof(struct drm_display_mode), GFP_KERNEL);
if (!nmode)
return NULL;
if (drm_mode_object_get(dev, &nmode->base, DRM_MODE_OBJECT_MODE)) {
kfree(nmode);
return NULL;
}
return nmode;
}
EXPORT_SYMBOL(drm_mode_create);
/**
* drm_mode_destroy - remove a mode
* @dev: DRM device
* @mode: mode to remove
*
* Free @mode's unique identifier, then free it.
*/
void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode)
{
if (!mode)
return;
drm_mode_object_put(dev, &mode->base);
kfree(mode);
}
EXPORT_SYMBOL(drm_mode_destroy);
/**
* drm_mode_probed_add - add a mode to a connector's probed mode list
* @connector: connector the new mode
* @mode: mode data
*
* Add @mode to @connector's mode list for later use.
*/
void drm_mode_probed_add(struct drm_connector *connector,
struct drm_display_mode *mode)
{
WARN_ON(!mutex_is_locked(&connector->dev->mode_config.mutex));
list_add_tail(&mode->head, &connector->probed_modes);
}
EXPORT_SYMBOL(drm_mode_probed_add);
/** /**
* drm_cvt_mode -create a modeline based on CVT algorithm * drm_cvt_mode -create a modeline based on CVT algorithm
* @dev: DRM device * @dev: DRM device
......
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