Commit c3c50e8b authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Dave Airlie

drm: Add drm_mode_copy()

Add a helper function to copy a display mode. Use it in
drm_mode_duplicate() and nouveau mode_fixup hooks.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent d63f5e6b
...@@ -713,6 +713,27 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags) ...@@ -713,6 +713,27 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags)
EXPORT_SYMBOL(drm_mode_set_crtcinfo); EXPORT_SYMBOL(drm_mode_set_crtcinfo);
/**
* drm_mode_copy - copy the mode
* @dst: mode to overwrite
* @src: mode to copy
*
* LOCKING:
* None.
*
* Copy an existing mode into another mode, preserving the object id
* of the destination mode.
*/
void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src)
{
int id = dst->base.id;
*dst = *src;
dst->base.id = id;
INIT_LIST_HEAD(&dst->head);
}
EXPORT_SYMBOL(drm_mode_copy);
/** /**
* drm_mode_duplicate - allocate and duplicate an existing mode * drm_mode_duplicate - allocate and duplicate an existing mode
* @m: mode to duplicate * @m: mode to duplicate
...@@ -727,16 +748,13 @@ struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, ...@@ -727,16 +748,13 @@ struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
const struct drm_display_mode *mode) const struct drm_display_mode *mode)
{ {
struct drm_display_mode *nmode; struct drm_display_mode *nmode;
int new_id;
nmode = drm_mode_create(dev); nmode = drm_mode_create(dev);
if (!nmode) if (!nmode)
return NULL; return NULL;
new_id = nmode->base.id; drm_mode_copy(nmode, mode);
*nmode = *mode;
nmode->base.id = new_id;
INIT_LIST_HEAD(&nmode->head);
return nmode; return nmode;
} }
EXPORT_SYMBOL(drm_mode_duplicate); EXPORT_SYMBOL(drm_mode_duplicate);
......
...@@ -190,11 +190,8 @@ nv50_dac_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, ...@@ -190,11 +190,8 @@ nv50_dac_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
} }
if (connector->scaling_mode != DRM_MODE_SCALE_NONE && if (connector->scaling_mode != DRM_MODE_SCALE_NONE &&
connector->native_mode) { connector->native_mode)
int id = adjusted_mode->base.id; drm_mode_copy(adjusted_mode, connector->native_mode);
*adjusted_mode = *connector->native_mode;
adjusted_mode->base.id = id;
}
return true; return true;
} }
......
...@@ -342,11 +342,8 @@ nv50_sor_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, ...@@ -342,11 +342,8 @@ nv50_sor_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
} }
if (connector->scaling_mode != DRM_MODE_SCALE_NONE && if (connector->scaling_mode != DRM_MODE_SCALE_NONE &&
connector->native_mode) { connector->native_mode)
int id = adjusted_mode->base.id; drm_mode_copy(adjusted_mode, connector->native_mode);
*adjusted_mode = *connector->native_mode;
adjusted_mode->base.id = id;
}
return true; return true;
} }
......
...@@ -855,6 +855,7 @@ extern struct edid *drm_get_edid(struct drm_connector *connector, ...@@ -855,6 +855,7 @@ extern struct edid *drm_get_edid(struct drm_connector *connector,
extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode); extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode); extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
extern void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src);
extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
const struct drm_display_mode *mode); const struct drm_display_mode *mode);
extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode); extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode);
......
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