Skip to content

Commit

Permalink
Merge branch 'drm-fb-helper' of git://people.freedesktop.org/~danvet/…
Browse files Browse the repository at this point in the history
…drm into drm-next

This is the drm fb helper cleanup, mostly motivated by strange things I've
seen in my locking rework and the i915 modeset revamp. Compared to the
original submission I've reinstated the setup flexibility you'd like to
retain, kerneldoc has been reviewed by Laurent Pinchart and Rob Clark
reviewed the code changes.

Quick overview of the changes:
- Cleaned-up library interface for drivers using the fb helper, also
  simplified the fb allocation callback since no driver supported
  reallocating the fb on-the-fly. And the fbdev/fbcon code keeps pointers
  to the old mapping around anyway, so reallocating backing storage will
  be much more work.
- No longer call the crtc helper "disable everything" function at init
  time, but allow drivers to do so. Motivated by i915's fastboot effort
  and allows us to drop a bunch of noop dummy functions just to avoid
  calling NULL function pointers from i915.ko.
- Properly clear old state when doing modeset calls, the fb helper left
  some old modes in there and unconditionally set an fb (even when
  disabling a crtc). The crtc helpers didn't care, but i915 modeset code
  can now drop a few special cases.
- Full kerneldoc for the fb helper. Yay!
- My version of the "don't sleep in panic ->unblank calls". The patch is
  already in -mm, I guess Andrew can drop it as soon as this pull lands in
  drm-next.

* 'drm-fb-helper' of git://people.freedesktop.org/~danvet/drm:
  drm/fb-helper: remove unused members of struct drm_fb_helper
  drm/fb-helper: don't sleep for screen unblank when an oopps is in progress
  drm/fb-helper: improve kerneldoc
  drm/<drivers>: simplify ->fb_probe callback
  drm/fb-helper: streamline drm_fb_helper_single_fb_probe
  drm/fb-helper: directly call set_par from the hotplug handler
  drm/fb-helper: fixup set_config semantics
  drm/i915: rip out helper->disable noop functions
  drm/fb-helper: don't disable everything in initial_config
  drm/tegra: don't set up initial fbcon config twice
  drm/fb-helper: unexport drm_fb_helper_single_fb_probe
  drm/fb-helper: unexport drm_fb_helper_panic
  drm/fb-helper: kill drm_fb_helper_restore
  drm: review locking for drm_fb_helper_restore_fbdev_mode
  • Loading branch information
Dave Airlie committed Feb 15, 2013
2 parents f934ec8 + a065b46 commit 3314fdf
Show file tree
Hide file tree
Showing 27 changed files with 298 additions and 290 deletions.
1 change: 1 addition & 0 deletions Documentation/DocBook/drm.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2143,6 +2143,7 @@ void intel_crt_init(struct drm_device *dev)
<title>fbdev Helper Functions Reference</title>
!Pdrivers/gpu/drm/drm_fb_helper.c fbdev helpers
!Edrivers/gpu/drm/drm_fb_helper.c
!Iinclude/drm/drm_fb_helper.h
</sect2>
<sect2>
<title>Display Port Helper Functions Reference</title>
Expand Down
26 changes: 8 additions & 18 deletions drivers/gpu/drm/ast/ast_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <drm/drmP.h>
#include <drm/drm_crtc.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_crtc_helper.h>
#include "ast_drv.h"

static void ast_dirty_update(struct ast_fbdev *afbdev,
Expand Down Expand Up @@ -145,9 +146,10 @@ static int astfb_create_object(struct ast_fbdev *afbdev,
return ret;
}

static int astfb_create(struct ast_fbdev *afbdev,
static int astfb_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes)
{
struct ast_fbdev *afbdev = (struct ast_fbdev *)helper;
struct drm_device *dev = afbdev->helper.dev;
struct drm_mode_fb_cmd2 mode_cmd;
struct drm_framebuffer *fb;
Expand Down Expand Up @@ -248,26 +250,10 @@ static void ast_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
*blue = ast_crtc->lut_b[regno] << 8;
}

static int ast_find_or_create_single(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes)
{
struct ast_fbdev *afbdev = (struct ast_fbdev *)helper;
int new_fb = 0;
int ret;

if (!helper->fb) {
ret = astfb_create(afbdev, sizes);
if (ret)
return ret;
new_fb = 1;
}
return new_fb;
}

static struct drm_fb_helper_funcs ast_fb_helper_funcs = {
.gamma_set = ast_fb_gamma_set,
.gamma_get = ast_fb_gamma_get,
.fb_probe = ast_find_or_create_single,
.fb_probe = astfb_create,
};

static void ast_fbdev_destroy(struct drm_device *dev,
Expand Down Expand Up @@ -314,6 +300,10 @@ int ast_fbdev_init(struct drm_device *dev)
}

drm_fb_helper_single_add_all_connectors(&afbdev->helper);

/* disable all the possible outputs/crtcs before entering KMS mode */
drm_helper_disable_unused_functions(dev);

drm_fb_helper_initial_config(&afbdev->helper, 32);
return 0;
}
Expand Down
26 changes: 7 additions & 19 deletions drivers/gpu/drm/cirrus/cirrus_fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <linux/module.h>
#include <drm/drmP.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_crtc_helper.h>

#include <linux/fb.h>

Expand Down Expand Up @@ -120,9 +121,10 @@ static int cirrusfb_create_object(struct cirrus_fbdev *afbdev,
return ret;
}

static int cirrusfb_create(struct cirrus_fbdev *gfbdev,
static int cirrusfb_create(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes)
{
struct cirrus_fbdev *gfbdev = (struct cirrus_fbdev *)helper;
struct drm_device *dev = gfbdev->helper.dev;
struct cirrus_device *cdev = gfbdev->helper.dev->dev_private;
struct fb_info *info;
Expand Down Expand Up @@ -219,23 +221,6 @@ static int cirrusfb_create(struct cirrus_fbdev *gfbdev,
return ret;
}

static int cirrus_fb_find_or_create_single(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size
*sizes)
{
struct cirrus_fbdev *gfbdev = (struct cirrus_fbdev *)helper;
int new_fb = 0;
int ret;

if (!helper->fb) {
ret = cirrusfb_create(gfbdev, sizes);
if (ret)
return ret;
new_fb = 1;
}
return new_fb;
}

static int cirrus_fbdev_destroy(struct drm_device *dev,
struct cirrus_fbdev *gfbdev)
{
Expand Down Expand Up @@ -267,7 +252,7 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,
static struct drm_fb_helper_funcs cirrus_fb_helper_funcs = {
.gamma_set = cirrus_crtc_fb_gamma_set,
.gamma_get = cirrus_crtc_fb_gamma_get,
.fb_probe = cirrus_fb_find_or_create_single,
.fb_probe = cirrusfb_create,
};

int cirrus_fbdev_init(struct cirrus_device *cdev)
Expand All @@ -291,6 +276,9 @@ int cirrus_fbdev_init(struct cirrus_device *cdev)
return ret;
}
drm_fb_helper_single_add_all_connectors(&gfbdev->helper);

/* disable all the possible outputs/crtcs before entering KMS mode */
drm_helper_disable_unused_functions(cdev->dev);
drm_fb_helper_initial_config(&gfbdev->helper, bpp_sel);

return 0;
Expand Down
16 changes: 15 additions & 1 deletion drivers/gpu/drm/drm_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,23 @@ void drm_modeset_unlock_all(struct drm_device *dev)

mutex_unlock(&dev->mode_config.mutex);
}

EXPORT_SYMBOL(drm_modeset_unlock_all);

/**
* drm_warn_on_modeset_not_all_locked - check that all modeset locks are locked
* @dev: device
*/
void drm_warn_on_modeset_not_all_locked(struct drm_device *dev)
{
struct drm_crtc *crtc;

list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
WARN_ON(!mutex_is_locked(&crtc->mutex));

WARN_ON(!mutex_is_locked(&dev->mode_config.mutex));
}
EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);

/* Avoid boilerplate. I'm tired of typing. */
#define DRM_ENUM_NAME_FN(fnname, list) \
char *fnname(int val) \
Expand Down
22 changes: 6 additions & 16 deletions drivers/gpu/drm/drm_fb_cma_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,23 +275,8 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
return ret;
}

static int drm_fbdev_cma_probe(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes)
{
int ret = 0;

if (!helper->fb) {
ret = drm_fbdev_cma_create(helper, sizes);
if (ret < 0)
return ret;
ret = 1;
}

return ret;
}

static struct drm_fb_helper_funcs drm_fb_cma_helper_funcs = {
.fb_probe = drm_fbdev_cma_probe,
.fb_probe = drm_fbdev_cma_create,
};

/**
Expand Down Expand Up @@ -333,6 +318,9 @@ struct drm_fbdev_cma *drm_fbdev_cma_init(struct drm_device *dev,

}

/* disable all the possible outputs/crtcs before entering KMS mode */
drm_helper_disable_unused_functions(dev);

ret = drm_fb_helper_initial_config(helper, preferred_bpp);
if (ret < 0) {
dev_err(dev->dev, "Failed to set inital hw configuration.\n");
Expand Down Expand Up @@ -389,8 +377,10 @@ EXPORT_SYMBOL_GPL(drm_fbdev_cma_fini);
*/
void drm_fbdev_cma_restore_mode(struct drm_fbdev_cma *fbdev_cma)
{
drm_modeset_lock_all(dev);
if (fbdev_cma)
drm_fb_helper_restore_fbdev_mode(&fbdev_cma->fb_helper);
drm_modeset_unlock_all(dev);
}
EXPORT_SYMBOL_GPL(drm_fbdev_cma_restore_mode);

Expand Down
Loading

0 comments on commit 3314fdf

Please sign in to comment.