modesetting: reorganise out crtc/outputs are allocated.

Use subclassing from the drivers to allocate the objects. This saves
two objects being allocated for each crtc/output and generally makes
exit paths cleaner.
main
Dave Airlie 2008-05-30 11:25:41 +10:00
parent df8cd54286
commit 98c5cf7f6f
11 changed files with 181 additions and 215 deletions

View File

@ -232,27 +232,19 @@ void drm_framebuffer_destroy(struct drm_framebuffer *fb)
EXPORT_SYMBOL(drm_framebuffer_destroy); EXPORT_SYMBOL(drm_framebuffer_destroy);
/** /**
* drm_crtc_create - create a new CRTC object * drm_crtc_init - Initialise a new CRTC object
* @dev: DRM device * @dev: DRM device
* @crtc: CRTC object to init
* @funcs: callbacks for the new CRTC * @funcs: callbacks for the new CRTC
* *
* LOCKING: * LOCKING:
* Caller must hold mode config lock. * Caller must hold mode config lock.
* *
* Creates a new CRTC object and adds it to @dev's mode_config structure. * Inits a new object created as base part of an driver crtc object.
*
* RETURNS:
* Pointer to new CRTC object or NULL on error.
*/ */
struct drm_crtc *drm_crtc_create(struct drm_device *dev, void drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
const struct drm_crtc_funcs *funcs) const struct drm_crtc_funcs *funcs)
{ {
struct drm_crtc *crtc;
crtc = kzalloc(sizeof(struct drm_crtc), GFP_KERNEL);
if (!crtc)
return NULL;
crtc->dev = dev; crtc->dev = dev;
crtc->funcs = funcs; crtc->funcs = funcs;
@ -260,34 +252,28 @@ struct drm_crtc *drm_crtc_create(struct drm_device *dev,
list_add_tail(&crtc->head, &dev->mode_config.crtc_list); list_add_tail(&crtc->head, &dev->mode_config.crtc_list);
dev->mode_config.num_crtc++; dev->mode_config.num_crtc++;
return crtc;
} }
EXPORT_SYMBOL(drm_crtc_create); EXPORT_SYMBOL(drm_crtc_init);
/** /**
* drm_crtc_destroy - remove a CRTC object * drm_crtc_cleanup - Cleans up the core crtc usage.
* @crtc: CRTC to remove * @crtc: CRTC to cleanup
* *
* LOCKING: * LOCKING:
* Caller must hold mode config lock. * Caller must hold mode config lock.
* *
* Cleanup @crtc. Calls @crtc's cleanup function, then removes @crtc from * Cleanup @crtc. Removes from drm modesetting space
* its associated DRM device's mode_config. Frees it afterwards. * does NOT free object, caller does that.
*/ */
void drm_crtc_destroy(struct drm_crtc *crtc) void drm_crtc_cleanup(struct drm_crtc *crtc)
{ {
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
if (crtc->funcs->cleanup)
(*crtc->funcs->cleanup)(crtc);
drm_idr_put(dev, crtc->id); drm_idr_put(dev, crtc->id);
list_del(&crtc->head); list_del(&crtc->head);
dev->mode_config.num_crtc--; dev->mode_config.num_crtc--;
kfree(crtc);
} }
EXPORT_SYMBOL(drm_crtc_destroy); EXPORT_SYMBOL(drm_crtc_cleanup);
/** /**
* drm_crtc_in_use - check if a given CRTC is in a mode_config * drm_crtc_in_use - check if a given CRTC is in a mode_config
@ -481,30 +467,23 @@ void drm_mode_remove(struct drm_output *output, struct drm_display_mode *mode)
EXPORT_SYMBOL(drm_mode_remove); EXPORT_SYMBOL(drm_mode_remove);
/** /**
* drm_output_create - create a new output * drm_output_init - Init a preallocated output
* @dev: DRM device * @dev: DRM device
* @output: the output to init
* @funcs: callbacks for this output * @funcs: callbacks for this output
* @name: user visible name of the output * @name: user visible name of the output
* *
* LOCKING: * LOCKING:
* Caller must hold @dev's mode_config lock. * Caller must hold @dev's mode_config lock.
* *
* Creates a new drm_output structure and adds it to @dev's mode_config * Initialises a preallocated output. Outputs should be
* structure. * subclassed as part of driver output objects.
*
* RETURNS:
* Pointer to the new output or NULL on error.
*/ */
struct drm_output *drm_output_create(struct drm_device *dev, void drm_output_init(struct drm_device *dev,
struct drm_output *output,
const struct drm_output_funcs *funcs, const struct drm_output_funcs *funcs,
int output_type) int output_type)
{ {
struct drm_output *output = NULL;
output = kzalloc(sizeof(struct drm_output), GFP_KERNEL);
if (!output)
return NULL;
output->dev = dev; output->dev = dev;
output->funcs = funcs; output->funcs = funcs;
output->id = drm_idr_get(dev, output); output->id = drm_idr_get(dev, output);
@ -526,30 +505,23 @@ struct drm_output *drm_output_create(struct drm_device *dev,
drm_output_attach_property(output, dev->mode_config.dpms_property, 0); drm_output_attach_property(output, dev->mode_config.dpms_property, 0);
mutex_unlock(&dev->mode_config.mutex); mutex_unlock(&dev->mode_config.mutex);
return output;
} }
EXPORT_SYMBOL(drm_output_create); EXPORT_SYMBOL(drm_output_init);
/** /**
* drm_output_destroy - remove an output * drm_output_cleanup - cleans up an initialised output
* @output: output to remove * @output: output to cleanup
* *
* LOCKING: * LOCKING:
* Caller must hold @dev's mode_config lock. * Caller must hold @dev's mode_config lock.
* *
* Call @output's cleanup function, then remove the output from the DRM * Cleans up the output but doesn't free the object.
* mode_config after freeing @output's modes.
*/ */
void drm_output_destroy(struct drm_output *output) void drm_output_cleanup(struct drm_output *output)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_display_mode *mode, *t; struct drm_display_mode *mode, *t;
if (*output->funcs->cleanup)
(*output->funcs->cleanup)(output);
list_for_each_entry_safe(mode, t, &output->probed_modes, head) list_for_each_entry_safe(mode, t, &output->probed_modes, head)
drm_mode_remove(output, mode); drm_mode_remove(output, mode);
@ -563,9 +535,8 @@ void drm_output_destroy(struct drm_output *output)
drm_idr_put(dev, output->id); drm_idr_put(dev, output->id);
list_del(&output->head); list_del(&output->head);
mutex_unlock(&dev->mode_config.mutex); mutex_unlock(&dev->mode_config.mutex);
kfree(output);
} }
EXPORT_SYMBOL(drm_output_destroy); EXPORT_SYMBOL(drm_output_cleanup);
/** /**
@ -793,7 +764,7 @@ void drm_mode_config_cleanup(struct drm_device *dev)
list_for_each_entry_safe(output, ot, &dev->mode_config.output_list, head) { list_for_each_entry_safe(output, ot, &dev->mode_config.output_list, head) {
drm_sysfs_output_remove(output); drm_sysfs_output_remove(output);
drm_output_destroy(output); output->funcs->destroy(output);
} }
list_for_each_entry_safe(property, pt, &dev->mode_config.property_list, head) { list_for_each_entry_safe(property, pt, &dev->mode_config.property_list, head) {
@ -809,7 +780,7 @@ void drm_mode_config_cleanup(struct drm_device *dev)
} }
list_for_each_entry_safe(crtc, ct, &dev->mode_config.crtc_list, head) { list_for_each_entry_safe(crtc, ct, &dev->mode_config.crtc_list, head) {
drm_crtc_destroy(crtc); crtc->funcs->destroy(crtc);
} }
} }

View File

@ -291,7 +291,7 @@ struct drm_output;
* @mode_fixup: fixup proposed mode * @mode_fixup: fixup proposed mode
* @mode_set: set the desired mode on the CRTC * @mode_set: set the desired mode on the CRTC
* @gamma_set: specify color ramp for CRTC * @gamma_set: specify color ramp for CRTC
* @cleanup: cleanup driver private state prior to close * @destroy: deinit and free object.
* *
* The drm_crtc_funcs structure is the central CRTC management structure * The drm_crtc_funcs structure is the central CRTC management structure
* in the DRM. Each CRTC controls one or more outputs (note that the name * in the DRM. Each CRTC controls one or more outputs (note that the name
@ -322,8 +322,8 @@ struct drm_crtc_funcs {
/* Set gamma on the CRTC */ /* Set gamma on the CRTC */
void (*gamma_set)(struct drm_crtc *crtc, u16 r, u16 g, u16 b, void (*gamma_set)(struct drm_crtc *crtc, u16 r, u16 g, u16 b,
int regno); int regno);
/* Driver cleanup routine */ /* Object destroy routine */
void (*cleanup)(struct drm_crtc *crtc); void (*destroy)(struct drm_crtc *crtc);
int (*set_config)(struct drm_mode_set *set); int (*set_config)(struct drm_mode_set *set);
}; };
@ -337,7 +337,6 @@ struct drm_crtc_funcs {
* @desired_x: desired x for desired_mode * @desired_x: desired x for desired_mode
* @desired_y: desired y for desired_mode * @desired_y: desired y for desired_mode
* @funcs: CRTC control functions * @funcs: CRTC control functions
* @driver_private: arbitrary driver data
* *
* Each CRTC may have one or more outputs associated with it. This structure * Each CRTC may have one or more outputs associated with it. This structure
* allows the CRTC to be controlled. * allows the CRTC to be controlled.
@ -359,15 +358,11 @@ struct drm_crtc {
struct drm_display_mode *desired_mode; struct drm_display_mode *desired_mode;
int desired_x, desired_y; int desired_x, desired_y;
const struct drm_crtc_funcs *funcs; const struct drm_crtc_funcs *funcs;
void *driver_private;
/* if you are using the helper */ /* if you are using the helper */
void *helper_private; void *helper_private;
}; };
extern struct drm_crtc *drm_crtc_create(struct drm_device *dev,
const struct drm_crtc_funcs *funcs);
/** /**
* drm_output_funcs - control outputs on a given device * drm_output_funcs - control outputs on a given device
* @init: setup this output * @init: setup this output
@ -380,7 +375,7 @@ extern struct drm_crtc *drm_crtc_create(struct drm_device *dev,
* @detect: is this output active? * @detect: is this output active?
* @get_modes: get mode list for this output * @get_modes: get mode list for this output
* @set_property: property for this output may need update * @set_property: property for this output may need update
* @cleanup: output is going away, cleanup * @destroy: make object go away
* *
* Each CRTC may have one or more outputs attached to it. The functions * Each CRTC may have one or more outputs attached to it. The functions
* below allow the core DRM code to control outputs, enumerate available modes, * below allow the core DRM code to control outputs, enumerate available modes,
@ -395,7 +390,7 @@ struct drm_output_funcs {
int (*get_modes)(struct drm_output *output); int (*get_modes)(struct drm_output *output);
bool (*set_property)(struct drm_output *output, struct drm_property *property, bool (*set_property)(struct drm_output *output, struct drm_property *property,
uint64_t val); uint64_t val);
void (*cleanup)(struct drm_output *output); void (*destroy)(struct drm_output *output);
int (*mode_valid)(struct drm_output *output, int (*mode_valid)(struct drm_output *output,
struct drm_display_mode *mode); struct drm_display_mode *mode);
@ -416,7 +411,6 @@ struct drm_output_funcs {
* @initial_y: initial y position for this output * @initial_y: initial y position for this output
* @status: output connected? * @status: output connected?
* @funcs: output control functions * @funcs: output control functions
* @driver_private: private driver data
* *
* Each output may be connected to one or more CRTCs, or may be clonable by * Each output may be connected to one or more CRTCs, or may be clonable by
* another output if they can share a CRTC. Each output also has a specific * another output if they can share a CRTC. Each output also has a specific
@ -447,7 +441,6 @@ struct drm_output {
struct drm_display_info display_info; struct drm_display_info display_info;
const struct drm_output_funcs *funcs; const struct drm_output_funcs *funcs;
void *driver_private;
struct list_head user_modes; struct list_head user_modes;
struct drm_property_blob *edid_blob_ptr; struct drm_property_blob *edid_blob_ptr;
@ -532,13 +525,21 @@ struct drm_mode_config {
uint32_t hotplug_counter; uint32_t hotplug_counter;
}; };
struct drm_output *drm_output_create(struct drm_device *dev,
extern void drm_crtc_init(struct drm_device *dev,
struct drm_crtc *crtc,
const struct drm_crtc_funcs *funcs);
extern void drm_crtc_cleanup(struct drm_crtc *crtc);
void drm_output_init(struct drm_device *dev,
struct drm_output *output,
const struct drm_output_funcs *funcs, const struct drm_output_funcs *funcs,
int type); int output_type);
void drm_output_cleanup(struct drm_output *output);
extern char *drm_get_output_name(struct drm_output *output); extern char *drm_get_output_name(struct drm_output *output);
extern char *drm_get_dpms_name(int val); extern char *drm_get_dpms_name(int val);
extern void drm_output_destroy(struct drm_output *output);
extern void drm_fb_release(struct file *filp); extern void drm_fb_release(struct file *filp);
extern struct edid *drm_get_edid(struct drm_output *output, extern struct edid *drm_get_edid(struct drm_output *output,

View File

@ -96,7 +96,7 @@ static void intel_crt_mode_set(struct drm_output *output,
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_crtc *crtc = output->crtc; struct drm_crtc *crtc = output->crtc;
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
int dpll_md_reg; int dpll_md_reg;
u32 adpa, dpll_md; u32 adpa, dpll_md;
@ -166,7 +166,7 @@ static bool intel_crt_detect_hotplug(struct drm_output *output)
static bool intel_crt_detect_ddc(struct drm_output *output) static bool intel_crt_detect_ddc(struct drm_output *output)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
/* CRT should always be at 0, but check anyway */ /* CRT should always be at 0, but check anyway */
if (intel_output->type != INTEL_OUTPUT_ANALOG) if (intel_output->type != INTEL_OUTPUT_ANALOG)
@ -195,10 +195,11 @@ static enum drm_output_status intel_crt_detect(struct drm_output *output)
static void intel_crt_destroy(struct drm_output *output) static void intel_crt_destroy(struct drm_output *output)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
intel_i2c_destroy(intel_output->ddc_bus); intel_i2c_destroy(intel_output->ddc_bus);
kfree(output->driver_private); drm_output_cleanup(output);
kfree(output);
} }
static int intel_crt_get_modes(struct drm_output *output) static int intel_crt_get_modes(struct drm_output *output)
@ -235,7 +236,7 @@ static const struct drm_output_funcs intel_crt_output_funcs = {
.restore = intel_crt_restore, .restore = intel_crt_restore,
.detect = intel_crt_detect, .detect = intel_crt_detect,
.get_modes = intel_crt_get_modes, .get_modes = intel_crt_get_modes,
.cleanup = intel_crt_destroy, .destroy = intel_crt_destroy,
.set_property = intel_crt_set_property, .set_property = intel_crt_set_property,
.mode_valid = intel_crt_mode_valid, .mode_valid = intel_crt_mode_valid,
@ -246,24 +247,23 @@ void intel_crt_init(struct drm_device *dev)
struct drm_output *output; struct drm_output *output;
struct intel_output *intel_output; struct intel_output *intel_output;
output = drm_output_create(dev, &intel_crt_output_funcs, intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
DRM_MODE_OUTPUT_DAC); if (!intel_output)
intel_output = kmalloc(sizeof(struct intel_output), GFP_KERNEL);
if (!intel_output) {
drm_output_destroy(output);
return; return;
}
output = &intel_output->base;
drm_output_init(dev, &intel_output->base, &intel_crt_output_funcs, DRM_MODE_OUTPUT_DAC);
/* Set up the DDC bus. */ /* Set up the DDC bus. */
intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A");
if (!intel_output->ddc_bus) { if (!intel_output->ddc_bus) {
dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
"failed.\n"); "failed.\n");
intel_crt_destroy(output);
return; return;
} }
intel_output->type = INTEL_OUTPUT_ANALOG; intel_output->type = INTEL_OUTPUT_ANALOG;
output->driver_private = intel_output;
output->interlace_allowed = 0; output->interlace_allowed = 0;
output->doublescan_allowed = 0; output->doublescan_allowed = 0;

View File

@ -229,7 +229,7 @@ bool intel_pipe_has_type (struct drm_crtc *crtc, int type)
list_for_each_entry(l_entry, &mode_config->output_list, head) { list_for_each_entry(l_entry, &mode_config->output_list, head) {
if (l_entry->crtc == crtc) { if (l_entry->crtc == crtc) {
struct intel_output *intel_output = l_entry->driver_private; struct intel_output *intel_output = to_intel_output(l_entry);
if (intel_output->type == type) if (intel_output->type == type)
return true; return true;
} }
@ -344,7 +344,7 @@ intel_set_vblank(struct drm_device *dev)
int vbl_pipe = 0; int vbl_pipe = 0;
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
intel_crtc = crtc->driver_private; intel_crtc = to_intel_crtc(crtc);
if (crtc->enabled) if (crtc->enabled)
vbl_pipe |= (1<<intel_crtc->pipe); vbl_pipe |= (1<<intel_crtc->pipe);
@ -366,7 +366,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y)
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_i915_master_private *master_priv; struct drm_i915_master_private *master_priv;
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
unsigned long Start, Offset; unsigned long Start, Offset;
int dspbase = (pipe == 0 ? DSPAADDR : DSPBADDR); int dspbase = (pipe == 0 ? DSPAADDR : DSPBADDR);
@ -454,7 +454,7 @@ static void intel_crtc_dpms(struct drm_crtc *crtc, int mode)
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct drm_i915_master_private *master_priv; struct drm_i915_master_private *master_priv;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B;
int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR; int dspcntr_reg = (pipe == 0) ? DSPACNTR : DSPBCNTR;
@ -694,7 +694,7 @@ static void intel_crtc_mode_set(struct drm_crtc *crtc,
{ {
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
int fp_reg = (pipe == 0) ? FPA0 : FPB0; int fp_reg = (pipe == 0) ? FPA0 : FPB0;
int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B; int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B;
@ -719,7 +719,7 @@ static void intel_crtc_mode_set(struct drm_crtc *crtc,
struct drm_output *output; struct drm_output *output;
list_for_each_entry(output, &mode_config->output_list, head) { list_for_each_entry(output, &mode_config->output_list, head) {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
if (output->crtc != crtc) if (output->crtc != crtc)
continue; continue;
@ -947,7 +947,7 @@ void intel_crtc_load_lut(struct drm_crtc *crtc)
{ {
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int palreg = (intel_crtc->pipe == 0) ? PALETTE_A : PALETTE_B; int palreg = (intel_crtc->pipe == 0) ? PALETTE_A : PALETTE_B;
int i; int i;
@ -969,7 +969,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
{ {
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR; uint32_t control = (pipe == 0) ? CURACNTR : CURBCNTR;
uint32_t base = (pipe == 0) ? CURABASE : CURBBASE; uint32_t base = (pipe == 0) ? CURABASE : CURBBASE;
@ -1027,7 +1027,7 @@ static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
{ {
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
uint32_t temp = 0; uint32_t temp = 0;
uint32_t adder; uint32_t adder;
@ -1055,7 +1055,7 @@ static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
u16 blue, int regno) u16 blue, int regno)
{ {
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
intel_crtc->lut_r[regno] = red >> 8; intel_crtc->lut_r[regno] = red >> 8;
intel_crtc->lut_g[regno] = green >> 8; intel_crtc->lut_g[regno] = green >> 8;
@ -1087,7 +1087,7 @@ struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output,
int *dpms_mode) int *dpms_mode)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_crtc *intel_crtc; struct intel_crtc *intel_crtc;
struct drm_crtc *possible_crtc; struct drm_crtc *possible_crtc;
struct drm_crtc *supported_crtc =NULL; struct drm_crtc *supported_crtc =NULL;
@ -1109,7 +1109,7 @@ struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output,
if (output->crtc) { if (output->crtc) {
crtc = output->crtc; crtc = output->crtc;
/* Make sure the crtc and output are running */ /* Make sure the crtc and output are running */
intel_crtc = crtc->driver_private; intel_crtc = to_intel_crtc(crtc);
*dpms_mode = intel_crtc->dpms_mode; *dpms_mode = intel_crtc->dpms_mode;
if (intel_crtc->dpms_mode != DPMSModeOn) { if (intel_crtc->dpms_mode != DPMSModeOn) {
crtc->funcs->dpms(crtc, DPMSModeOn); crtc->funcs->dpms(crtc, DPMSModeOn);
@ -1144,7 +1144,7 @@ struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output,
output->crtc = crtc; output->crtc = crtc;
intel_output->load_detect_temp = TRUE; intel_output->load_detect_temp = TRUE;
intel_crtc = crtc->driver_private; intel_crtc = to_intel_crtc(crtc);
*dpms_mode = intel_crtc->dpms_mode; *dpms_mode = intel_crtc->dpms_mode;
if (!crtc->enabled) { if (!crtc->enabled) {
@ -1169,7 +1169,7 @@ struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output,
void intel_release_load_detect_pipe(struct drm_output *output, int dpms_mode) void intel_release_load_detect_pipe(struct drm_output *output, int dpms_mode)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct drm_crtc *crtc = output->crtc; struct drm_crtc *crtc = output->crtc;
if (intel_output->load_detect_temp) { if (intel_output->load_detect_temp) {
@ -1191,7 +1191,7 @@ void intel_release_load_detect_pipe(struct drm_output *output, int dpms_mode)
static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc) static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
u32 dpll = I915_READ((pipe == 0) ? DPLL_A : DPLL_B); u32 dpll = I915_READ((pipe == 0) ? DPLL_A : DPLL_B);
u32 fp; u32 fp;
@ -1269,7 +1269,7 @@ struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
struct drm_crtc *crtc) struct drm_crtc *crtc)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
struct drm_display_mode *mode; struct drm_display_mode *mode;
int htot = I915_READ((pipe == 0) ? HTOTAL_A : HTOTAL_B); int htot = I915_READ((pipe == 0) ? HTOTAL_A : HTOTAL_B);
@ -1297,6 +1297,14 @@ struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
return mode; return mode;
} }
static void intel_crtc_destroy(struct drm_crtc *crtc)
{
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
drm_crtc_cleanup(crtc);
kfree(intel_crtc);
}
static const struct drm_crtc_helper_funcs intel_helper_funcs = { static const struct drm_crtc_helper_funcs intel_helper_funcs = {
.mode_fixup = intel_crtc_mode_fixup, .mode_fixup = intel_crtc_mode_fixup,
.mode_set = intel_crtc_mode_set, .mode_set = intel_crtc_mode_set,
@ -1311,24 +1319,20 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
.cursor_move = intel_crtc_cursor_move, .cursor_move = intel_crtc_cursor_move,
.gamma_set = intel_crtc_gamma_set, .gamma_set = intel_crtc_gamma_set,
.set_config = drm_crtc_helper_set_config, .set_config = drm_crtc_helper_set_config,
.destroy = intel_crtc_destroy,
}; };
void intel_crtc_init(struct drm_device *dev, int pipe) void intel_crtc_init(struct drm_device *dev, int pipe)
{ {
struct drm_crtc *crtc;
struct intel_crtc *intel_crtc; struct intel_crtc *intel_crtc;
int i; int i;
crtc = drm_crtc_create(dev, &intel_crtc_funcs); intel_crtc = kzalloc(sizeof(struct intel_crtc), GFP_KERNEL);
if (crtc == NULL) if (intel_crtc == NULL)
return; return;
intel_crtc = kzalloc(sizeof(struct intel_crtc), GFP_KERNEL); drm_crtc_init(dev, &intel_crtc->base, &intel_crtc_funcs);
if (intel_crtc == NULL) {
kfree(crtc);
return;
}
intel_crtc->pipe = pipe; intel_crtc->pipe = pipe;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
@ -1339,9 +1343,7 @@ void intel_crtc_init(struct drm_device *dev, int pipe)
intel_crtc->cursor_addr = 0; intel_crtc->cursor_addr = 0;
intel_crtc->dpms_mode = DPMSModeOff; intel_crtc->dpms_mode = DPMSModeOff;
drm_crtc_helper_add(crtc, &intel_helper_funcs); drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs);
crtc->driver_private = intel_crtc;
} }
struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe) struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe)
@ -1349,7 +1351,7 @@ struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe)
struct drm_crtc *crtc = NULL; struct drm_crtc *crtc = NULL;
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
if (intel_crtc->pipe == pipe) if (intel_crtc->pipe == pipe)
break; break;
} }
@ -1363,7 +1365,7 @@ int intel_output_clones(struct drm_device *dev, int type_mask)
int entry = 0; int entry = 0;
list_for_each_entry(output, &dev->mode_config.output_list, head) { list_for_each_entry(output, &dev->mode_config.output_list, head) {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
if (type_mask & (1 << intel_output->type)) if (type_mask & (1 << intel_output->type))
index_mask |= (1 << entry); index_mask |= (1 << entry);
entry++; entry++;
@ -1392,7 +1394,7 @@ static void intel_setup_outputs(struct drm_device *dev)
intel_tv_init(dev); intel_tv_init(dev);
list_for_each_entry(output, &dev->mode_config.output_list, head) { list_for_each_entry(output, &dev->mode_config.output_list, head) {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
int crtc_mask = 0, clone_mask = 0; int crtc_mask = 0, clone_mask = 0;
/* valid crtcs */ /* valid crtcs */

View File

@ -47,6 +47,7 @@ struct intel_i2c_chan {
}; };
struct intel_output { struct intel_output {
struct drm_output base;
int type; int type;
struct intel_i2c_chan *i2c_bus; /* for control functions */ struct intel_i2c_chan *i2c_bus; /* for control functions */
struct intel_i2c_chan *ddc_bus; /* for DDC only stuff */ struct intel_i2c_chan *ddc_bus; /* for DDC only stuff */
@ -55,6 +56,7 @@ struct intel_output {
}; };
struct intel_crtc { struct intel_crtc {
struct drm_crtc base;
int pipe; int pipe;
int plane; int plane;
uint32_t cursor_addr; uint32_t cursor_addr;
@ -62,6 +64,9 @@ struct intel_crtc {
int dpms_mode; int dpms_mode;
}; };
#define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
#define to_intel_output(x) container_of(x, struct intel_output, base)
struct intel_i2c_chan *intel_i2c_create(struct drm_device *dev, const u32 reg, struct intel_i2c_chan *intel_i2c_create(struct drm_device *dev, const u32 reg,
const char *name); const char *name);
void intel_i2c_destroy(struct intel_i2c_chan *chan); void intel_i2c_destroy(struct intel_i2c_chan *chan);

View File

@ -88,7 +88,7 @@ struct intel_dvo_device intel_dvo_devices[] = {
static void intel_dvo_dpms(struct drm_output *output, int mode) static void intel_dvo_dpms(struct drm_output *output, int mode)
{ {
struct drm_i915_private *dev_priv = output->dev->dev_private; struct drm_i915_private *dev_priv = output->dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_dvo_device *dvo = intel_output->dev_priv; struct intel_dvo_device *dvo = intel_output->dev_priv;
u32 dvo_reg = dvo->dvo_reg; u32 dvo_reg = dvo->dvo_reg;
u32 temp = I915_READ(dvo_reg); u32 temp = I915_READ(dvo_reg);
@ -107,7 +107,7 @@ static void intel_dvo_dpms(struct drm_output *output, int mode)
static void intel_dvo_save(struct drm_output *output) static void intel_dvo_save(struct drm_output *output)
{ {
struct drm_i915_private *dev_priv = output->dev->dev_private; struct drm_i915_private *dev_priv = output->dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_dvo_device *dvo = intel_output->dev_priv; struct intel_dvo_device *dvo = intel_output->dev_priv;
/* Each output should probably just save the registers it touches, /* Each output should probably just save the registers it touches,
@ -123,7 +123,7 @@ static void intel_dvo_save(struct drm_output *output)
static void intel_dvo_restore(struct drm_output *output) static void intel_dvo_restore(struct drm_output *output)
{ {
struct drm_i915_private *dev_priv = output->dev->dev_private; struct drm_i915_private *dev_priv = output->dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_dvo_device *dvo = intel_output->dev_priv; struct intel_dvo_device *dvo = intel_output->dev_priv;
dvo->dev_ops->restore(dvo); dvo->dev_ops->restore(dvo);
@ -136,7 +136,7 @@ static void intel_dvo_restore(struct drm_output *output)
static int intel_dvo_mode_valid(struct drm_output *output, static int intel_dvo_mode_valid(struct drm_output *output,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_dvo_device *dvo = intel_output->dev_priv; struct intel_dvo_device *dvo = intel_output->dev_priv;
if (mode->flags & V_DBLSCAN) if (mode->flags & V_DBLSCAN)
@ -158,7 +158,7 @@ static bool intel_dvo_mode_fixup(struct drm_output *output,
struct drm_display_mode *mode, struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode) struct drm_display_mode *adjusted_mode)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_dvo_device *dvo = intel_output->dev_priv; struct intel_dvo_device *dvo = intel_output->dev_priv;
/* If we have timings from the BIOS for the panel, put them in /* If we have timings from the BIOS for the panel, put them in
@ -193,8 +193,8 @@ static void intel_dvo_mode_set(struct drm_output *output,
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = output->crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(output->crtc);
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_dvo_device *dvo = intel_output->dev_priv; struct intel_dvo_device *dvo = intel_output->dev_priv;
int pipe = intel_crtc->pipe; int pipe = intel_crtc->pipe;
u32 dvo_val; u32 dvo_val;
@ -249,7 +249,7 @@ static void intel_dvo_mode_set(struct drm_output *output,
*/ */
static enum drm_output_status intel_dvo_detect(struct drm_output *output) static enum drm_output_status intel_dvo_detect(struct drm_output *output)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_dvo_device *dvo = intel_output->dev_priv; struct intel_dvo_device *dvo = intel_output->dev_priv;
return dvo->dev_ops->detect(dvo); return dvo->dev_ops->detect(dvo);
@ -257,7 +257,7 @@ static enum drm_output_status intel_dvo_detect(struct drm_output *output)
static int intel_dvo_get_modes(struct drm_output *output) static int intel_dvo_get_modes(struct drm_output *output)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_dvo_device *dvo = intel_output->dev_priv; struct intel_dvo_device *dvo = intel_output->dev_priv;
/* We should probably have an i2c driver get_modes function for those /* We should probably have an i2c driver get_modes function for those
@ -291,7 +291,7 @@ static int intel_dvo_get_modes(struct drm_output *output)
static void intel_dvo_destroy (struct drm_output *output) static void intel_dvo_destroy (struct drm_output *output)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_dvo_device *dvo = intel_output->dev_priv; struct intel_dvo_device *dvo = intel_output->dev_priv;
if (dvo) { if (dvo) {
@ -302,14 +302,12 @@ static void intel_dvo_destroy (struct drm_output *output)
/* no need, in i830_dvoices[] now */ /* no need, in i830_dvoices[] now */
//kfree(dvo); //kfree(dvo);
} }
if (intel_output) {
if (intel_output->i2c_bus) if (intel_output->i2c_bus)
intel_i2c_destroy(intel_output->i2c_bus); intel_i2c_destroy(intel_output->i2c_bus);
if (intel_output->ddc_bus) if (intel_output->ddc_bus)
intel_i2c_destroy(intel_output->ddc_bus); intel_i2c_destroy(intel_output->ddc_bus);
kfree(intel_output); drm_output_cleanup(output);
output->driver_private = NULL; kfree(output);
}
} }
#ifdef RANDR_GET_CRTC_INTERFACE #ifdef RANDR_GET_CRTC_INTERFACE
@ -317,7 +315,7 @@ static struct drm_crtc *intel_dvo_get_crtc(struct drm_output *output)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_dvo_device *dvo = intel_output->dev_priv; struct intel_dvo_device *dvo = intel_output->dev_priv;
int pipe = !!(I915_READ(dvo->dvo_reg) & SDVO_PIPE_B_SELECT); int pipe = !!(I915_READ(dvo->dvo_reg) & SDVO_PIPE_B_SELECT);
@ -338,7 +336,7 @@ static const struct drm_output_funcs intel_dvo_output_funcs = {
.restore = intel_dvo_restore, .restore = intel_dvo_restore,
.detect = intel_dvo_detect, .detect = intel_dvo_detect,
.get_modes = intel_dvo_get_modes, .get_modes = intel_dvo_get_modes,
.cleanup = intel_dvo_destroy, .destroy = intel_dvo_destroy,
.mode_valid = intel_dvo_mode_valid, .mode_valid = intel_dvo_mode_valid,
}; };
@ -353,7 +351,7 @@ intel_dvo_get_current_mode (struct drm_output *output)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_dvo_device *dvo = intel_output->dev_priv; struct intel_dvo_device *dvo = intel_output->dev_priv;
uint32_t dvo_reg = dvo->dvo_reg; uint32_t dvo_reg = dvo->dvo_reg;
uint32_t dvo_val = I915_READ(dvo_reg); uint32_t dvo_val = I915_READ(dvo_reg);
@ -403,7 +401,7 @@ void intel_dvo_init(struct drm_device *dev)
/* Now, try to find a controller */ /* Now, try to find a controller */
for (i = 0; i < ARRAY_SIZE(intel_dvo_devices); i++) { for (i = 0; i < ARRAY_SIZE(intel_dvo_devices); i++) {
struct drm_output *output = NULL; struct drm_output *output = &intel_output->base;
int gpio; int gpio;
dvo = &intel_dvo_devices[i]; dvo = &intel_dvo_devices[i];
@ -445,22 +443,17 @@ void intel_dvo_init(struct drm_device *dev)
switch (dvo->type) { switch (dvo->type) {
case INTEL_DVO_CHIP_TMDS: case INTEL_DVO_CHIP_TMDS:
connector = ConnectorDVID; connector = ConnectorDVID;
output = drm_output_create(dev, &intel_dvo_output_funcs, drm_output_init(dev, output, &intel_dvo_output_funcs,
DRM_MODE_OUTPUT_TMDS); DRM_MODE_OUTPUT_TMDS);
break; break;
case INTEL_DVO_CHIP_LVDS: case INTEL_DVO_CHIP_LVDS:
connector = ConnectorLVDS; connector = ConnectorLVDS;
output = drm_output_create(dev, &intel_dvo_output_funcs, drm_output_init(dev, output, &intel_dvo_output_funcs,
DRM_MODE_OUTPUT_LVDS); DRM_MODE_OUTPUT_LVDS);
break; break;
} }
if (output == NULL) {
dvo->dev_ops->destroy(dvo);
goto free_i2c;
}
drm_output_helper_add(output, &intel_dvo_helper_funcs); drm_output_helper_add(output, &intel_dvo_helper_funcs);
output->driver_private = intel_output;
output->display_info.subpixel_order = SubPixelHorizontalRGB; output->display_info.subpixel_order = SubPixelHorizontalRGB;
output->interlace_allowed = false; output->interlace_allowed = false;
output->doublescan_allowed = false; output->doublescan_allowed = false;
@ -487,7 +480,6 @@ void intel_dvo_init(struct drm_device *dev)
return; return;
} }
free_i2c:
intel_i2c_destroy(intel_output->ddc_bus); intel_i2c_destroy(intel_output->ddc_bus);
/* Didn't find a chip, so tear down. */ /* Didn't find a chip, so tear down. */
if (i2cbus != NULL) if (i2cbus != NULL)

View File

@ -161,7 +161,7 @@ static bool intel_lvds_mode_fixup(struct drm_output *output,
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = output->crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(output->crtc);
struct drm_output *tmp_output; struct drm_output *tmp_output;
/* Should never happen!! */ /* Should never happen!! */
@ -241,7 +241,7 @@ static void intel_lvds_mode_set(struct drm_output *output,
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = output->crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(output->crtc);
u32 pfit_control; u32 pfit_control;
/* /*
@ -326,10 +326,11 @@ static int intel_lvds_get_modes(struct drm_output *output)
*/ */
static void intel_lvds_destroy(struct drm_output *output) static void intel_lvds_destroy(struct drm_output *output)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
intel_i2c_destroy(intel_output->ddc_bus); intel_i2c_destroy(intel_output->ddc_bus);
kfree(output->driver_private); drm_output_cleanup(output);
kfree(output);
} }
static const struct drm_output_helper_funcs intel_lvds_helper_funcs = { static const struct drm_output_helper_funcs intel_lvds_helper_funcs = {
@ -345,7 +346,7 @@ static const struct drm_output_funcs intel_lvds_output_funcs = {
.restore = intel_lvds_restore, .restore = intel_lvds_restore,
.detect = intel_lvds_detect, .detect = intel_lvds_detect,
.get_modes = intel_lvds_get_modes, .get_modes = intel_lvds_get_modes,
.cleanup = intel_lvds_destroy, .destroy = intel_lvds_destroy,
.mode_valid = intel_lvds_mode_valid, .mode_valid = intel_lvds_mode_valid,
}; };
@ -359,27 +360,25 @@ static const struct drm_output_funcs intel_lvds_output_funcs = {
void intel_lvds_init(struct drm_device *dev) void intel_lvds_init(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_output *output;
struct intel_output *intel_output; struct intel_output *intel_output;
struct drm_output *output;
struct drm_display_mode *scan; /* *modes, *bios_mode; */ struct drm_display_mode *scan; /* *modes, *bios_mode; */
struct drm_crtc *crtc; struct drm_crtc *crtc;
u32 lvds; u32 lvds;
int pipe; int pipe;
output = drm_output_create(dev, &intel_lvds_output_funcs,
DRM_MODE_OUTPUT_LVDS);
if (!output)
return;
intel_output = kmalloc(sizeof(struct intel_output), GFP_KERNEL); intel_output = kmalloc(sizeof(struct intel_output), GFP_KERNEL);
if (!intel_output) { if (!intel_output) {
drm_output_destroy(output);
return; return;
} }
output = &intel_output->base;
drm_output_init(dev, &intel_output->base, &intel_lvds_output_funcs,
DRM_MODE_OUTPUT_LVDS);
intel_output->type = INTEL_OUTPUT_LVDS; intel_output->type = INTEL_OUTPUT_LVDS;
drm_output_helper_add(output, &intel_lvds_helper_funcs); drm_output_helper_add(output, &intel_lvds_helper_funcs);
output->driver_private = intel_output;
output->display_info.subpixel_order = SubPixelHorizontalRGB; output->display_info.subpixel_order = SubPixelHorizontalRGB;
output->interlace_allowed = FALSE; output->interlace_allowed = FALSE;
output->doublescan_allowed = FALSE; output->doublescan_allowed = FALSE;
@ -400,6 +399,7 @@ void intel_lvds_init(struct drm_device *dev)
if (!intel_output->ddc_bus) { if (!intel_output->ddc_bus) {
dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
"failed.\n"); "failed.\n");
intel_lvds_destroy(output);
return; return;
} }
@ -487,5 +487,5 @@ out:
failed: failed:
DRM_DEBUG("No LVDS modes found, disabling.\n"); DRM_DEBUG("No LVDS modes found, disabling.\n");
drm_output_destroy(output); /* calls intel_lvds_destroy above */ intel_lvds_destroy(output);
} }

View File

@ -15,7 +15,7 @@
*/ */
bool intel_ddc_probe(struct drm_output *output) bool intel_ddc_probe(struct drm_output *output)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
u8 out_buf[] = { 0x0, 0x0}; u8 out_buf[] = { 0x0, 0x0};
u8 buf[2]; u8 buf[2];
int ret; int ret;
@ -49,7 +49,7 @@ bool intel_ddc_probe(struct drm_output *output)
*/ */
int intel_ddc_get_modes(struct drm_output *output) int intel_ddc_get_modes(struct drm_output *output)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct edid *edid; struct edid *edid;
int ret = 0; int ret = 0;

View File

@ -64,7 +64,7 @@ void intel_sdvo_write_sdvox(struct drm_output *output, u32 val)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
u32 bval = val, cval = val; u32 bval = val, cval = val;
int i; int i;
@ -91,7 +91,7 @@ void intel_sdvo_write_sdvox(struct drm_output *output, u32 val)
static bool intel_sdvo_read_byte(struct drm_output *output, u8 addr, static bool intel_sdvo_read_byte(struct drm_output *output, u8 addr,
u8 *ch) u8 *ch)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
u8 out_buf[2]; u8 out_buf[2];
u8 buf[2]; u8 buf[2];
@ -129,7 +129,7 @@ static bool intel_sdvo_read_byte(struct drm_output *output, u8 addr,
static bool intel_sdvo_write_byte(struct drm_output *output, int addr, static bool intel_sdvo_write_byte(struct drm_output *output, int addr,
u8 ch) u8 ch)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
u8 out_buf[2]; u8 out_buf[2];
struct i2c_msg msgs[] = { struct i2c_msg msgs[] = {
{ {
@ -201,7 +201,7 @@ const static struct _sdvo_cmd_name {
static void intel_sdvo_write_cmd(struct drm_output *output, u8 cmd, static void intel_sdvo_write_cmd(struct drm_output *output, u8 cmd,
void *args, int args_len) void *args, int args_len)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
int i; int i;
@ -242,7 +242,7 @@ static const char *cmd_status_names[] = {
static u8 intel_sdvo_read_response(struct drm_output *output, void *response, static u8 intel_sdvo_read_response(struct drm_output *output, void *response,
int response_len) int response_len)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
int i; int i;
u8 status; u8 status;
@ -493,7 +493,7 @@ static bool intel_sdvo_set_output_timing(struct drm_output *output,
static bool intel_sdvo_get_preferred_input_timing(struct drm_output *output, static bool intel_sdvo_get_preferred_input_timing(struct drm_output *output,
struct intel_sdvo_dtd *dtd) struct intel_sdvo_dtd *dtd)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
u8 status; u8 status;
@ -563,8 +563,8 @@ static void intel_sdvo_mode_set(struct drm_output *output,
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_crtc *crtc = output->crtc; struct drm_crtc *crtc = output->crtc;
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
u16 width, height; u16 width, height;
u16 h_blank_len, h_sync_len, v_blank_len, v_sync_len; u16 h_blank_len, h_sync_len, v_blank_len, v_sync_len;
@ -693,7 +693,7 @@ static void intel_sdvo_dpms(struct drm_output *output, int mode)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
u32 temp; u32 temp;
@ -743,7 +743,7 @@ static void intel_sdvo_save(struct drm_output *output)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
int o; int o;
@ -780,7 +780,7 @@ static void intel_sdvo_restore(struct drm_output *output)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
int o; int o;
int i; int i;
@ -828,7 +828,7 @@ static void intel_sdvo_restore(struct drm_output *output)
static int intel_sdvo_mode_valid(struct drm_output *output, static int intel_sdvo_mode_valid(struct drm_output *output,
struct drm_display_mode *mode) struct drm_display_mode *mode)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
if (mode->flags & V_DBLSCAN) if (mode->flags & V_DBLSCAN)
@ -863,7 +863,7 @@ struct drm_output* intel_sdvo_find(struct drm_device *dev, int sdvoB)
/* find the sdvo output */ /* find the sdvo output */
list_for_each_entry(output, &dev->mode_config.output_list, head) { list_for_each_entry(output, &dev->mode_config.output_list, head) {
iout = output->driver_private; iout = to_intel_output(output);
if (iout->type != INTEL_OUTPUT_SDVO) if (iout->type != INTEL_OUTPUT_SDVO)
continue; continue;
@ -961,15 +961,13 @@ static int intel_sdvo_get_modes(struct drm_output *output)
static void intel_sdvo_destroy(struct drm_output *output) static void intel_sdvo_destroy(struct drm_output *output)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
if (intel_output->i2c_bus) if (intel_output->i2c_bus)
intel_i2c_destroy(intel_output->i2c_bus); intel_i2c_destroy(intel_output->i2c_bus);
if (intel_output) { drm_output_cleanup(output);
kfree(intel_output); kfree(intel_output);
output->driver_private = NULL;
}
} }
static const struct drm_output_helper_funcs intel_sdvo_helper_funcs = { static const struct drm_output_helper_funcs intel_sdvo_helper_funcs = {
@ -985,7 +983,7 @@ static const struct drm_output_funcs intel_sdvo_output_funcs = {
.restore = intel_sdvo_restore, .restore = intel_sdvo_restore,
.detect = intel_sdvo_detect, .detect = intel_sdvo_detect,
.get_modes = intel_sdvo_get_modes, .get_modes = intel_sdvo_get_modes,
.cleanup = intel_sdvo_destroy, .destroy = intel_sdvo_destroy,
.mode_valid = intel_sdvo_mode_valid, .mode_valid = intel_sdvo_mode_valid,
}; };
@ -1000,21 +998,19 @@ void intel_sdvo_init(struct drm_device *dev, int output_device)
int i; int i;
int output_type, output_id; int output_type, output_id;
output = drm_output_create(dev, &intel_sdvo_output_funcs,
DRM_MODE_OUTPUT_NONE);
if (!output)
return;
intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL); intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL);
if (!intel_output) { if (!intel_output) {
drm_output_destroy(output);
return; return;
} }
output = &intel_output->base;
drm_output_init(dev, output, &intel_sdvo_output_funcs,
DRM_MODE_OUTPUT_NONE);
sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1); sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1);
intel_output->type = INTEL_OUTPUT_SDVO; intel_output->type = INTEL_OUTPUT_SDVO;
drm_output_helper_add(output, &intel_sdvo_helper_funcs); drm_output_helper_add(output, &intel_sdvo_helper_funcs);
output->driver_private = intel_output;
output->interlace_allowed = 0; output->interlace_allowed = 0;
output->doublescan_allowed = 0; output->doublescan_allowed = 0;
@ -1025,7 +1021,7 @@ void intel_sdvo_init(struct drm_device *dev, int output_device)
i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC"); i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC");
if (i2cbus == NULL) { if (i2cbus == NULL) {
drm_output_destroy(output); intel_sdvo_destroy(output);
return; return;
} }
@ -1049,7 +1045,7 @@ void intel_sdvo_init(struct drm_device *dev, int output_device)
if (!intel_sdvo_read_byte(output, i, &ch[i])) { if (!intel_sdvo_read_byte(output, i, &ch[i])) {
DRM_DEBUG("No SDVO device found on SDVO%c\n", DRM_DEBUG("No SDVO device found on SDVO%c\n",
output_device == SDVOB ? 'B' : 'C'); output_device == SDVOB ? 'B' : 'C');
drm_output_destroy(output); intel_sdvo_destroy(output);
return; return;
} }
} }
@ -1095,7 +1091,7 @@ void intel_sdvo_init(struct drm_device *dev, int output_device)
DRM_DEBUG("%s: No active RGB or TMDS outputs (0x%02x%02x)\n", DRM_DEBUG("%s: No active RGB or TMDS outputs (0x%02x%02x)\n",
SDVO_NAME(sdvo_priv), SDVO_NAME(sdvo_priv),
bytes[0], bytes[1]); bytes[0], bytes[1]);
drm_output_destroy(output); intel_sdvo_destroy(output);
return; return;
} }

View File

@ -920,7 +920,7 @@ intel_tv_save(struct drm_output *output)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_tv_priv *tv_priv = intel_output->dev_priv; struct intel_tv_priv *tv_priv = intel_output->dev_priv;
int i; int i;
@ -970,7 +970,7 @@ intel_tv_restore(struct drm_output *output)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_tv_priv *tv_priv = intel_output->dev_priv; struct intel_tv_priv *tv_priv = intel_output->dev_priv;
struct drm_crtc *crtc = output->crtc; struct drm_crtc *crtc = output->crtc;
struct intel_crtc *intel_crtc; struct intel_crtc *intel_crtc;
@ -980,7 +980,7 @@ intel_tv_restore(struct drm_output *output)
if (!crtc) if (!crtc)
return; return;
intel_crtc = crtc->driver_private; intel_crtc = to_intel_crtc(crtc);
I915_WRITE(TV_H_CTL_1, tv_priv->save_TV_H_CTL_1); I915_WRITE(TV_H_CTL_1, tv_priv->save_TV_H_CTL_1);
I915_WRITE(TV_H_CTL_2, tv_priv->save_TV_H_CTL_2); I915_WRITE(TV_H_CTL_2, tv_priv->save_TV_H_CTL_2);
I915_WRITE(TV_H_CTL_3, tv_priv->save_TV_H_CTL_3); I915_WRITE(TV_H_CTL_3, tv_priv->save_TV_H_CTL_3);
@ -1069,7 +1069,7 @@ intel_tv_mode_lookup (char *tv_format)
static const struct tv_mode * static const struct tv_mode *
intel_tv_mode_find (struct drm_output *output) intel_tv_mode_find (struct drm_output *output)
{ {
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_tv_priv *tv_priv = intel_output->dev_priv; struct intel_tv_priv *tv_priv = intel_output->dev_priv;
return intel_tv_mode_lookup(tv_priv->tv_format); return intel_tv_mode_lookup(tv_priv->tv_format);
@ -1117,8 +1117,8 @@ intel_tv_mode_set(struct drm_output *output, struct drm_display_mode *mode,
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_crtc *crtc = output->crtc; struct drm_crtc *crtc = output->crtc;
struct intel_crtc *intel_crtc = crtc->driver_private; struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_tv_priv *tv_priv = intel_output->dev_priv; struct intel_tv_priv *tv_priv = intel_output->dev_priv;
const struct tv_mode *tv_mode = intel_tv_mode_find(output); const struct tv_mode *tv_mode = intel_tv_mode_find(output);
u32 tv_ctl; u32 tv_ctl;
@ -1359,7 +1359,7 @@ intel_tv_detect_type (struct drm_crtc *crtc, struct drm_output *output)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
u32 pipeastat, pipeastat_save; u32 pipeastat, pipeastat_save;
u32 tv_ctl, save_tv_ctl; u32 tv_ctl, save_tv_ctl;
u32 tv_dac, save_tv_dac; u32 tv_dac, save_tv_dac;
@ -1440,7 +1440,7 @@ intel_tv_detect(struct drm_output *output)
{ {
struct drm_crtc *crtc; struct drm_crtc *crtc;
struct drm_display_mode mode; struct drm_display_mode mode;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_tv_priv *tv_priv = intel_output->dev_priv; struct intel_tv_priv *tv_priv = intel_output->dev_priv;
int dpms_mode; int dpms_mode;
int type = tv_priv->type; int type = tv_priv->type;
@ -1547,17 +1547,20 @@ intel_tv_get_modes(struct drm_output *output)
static void static void
intel_tv_destroy (struct drm_output *output) intel_tv_destroy (struct drm_output *output)
{ {
if (output->driver_private) struct intel_output *intel_output = to_intel_output(output);
drm_free(output->driver_private, sizeof(struct intel_tv_priv),
drm_output_cleanup(output);
drm_free(intel_output, sizeof(struct intel_output) + sizeof(struct intel_tv_priv),
DRM_MEM_DRIVER); DRM_MEM_DRIVER);
} }
static bool static bool
intel_tv_set_property(struct drm_output *output, struct drm_property *property, intel_tv_set_property(struct drm_output *output, struct drm_property *property,
uint64_t val) uint64_t val)
{ {
struct drm_device *dev = output->dev; struct drm_device *dev = output->dev;
struct intel_output *intel_output = output->driver_private; struct intel_output *intel_output = to_intel_output(output);
struct intel_tv_priv *tv_priv = intel_output->dev_priv; struct intel_tv_priv *tv_priv = intel_output->dev_priv;
int ret = 0; int ret = 0;
@ -1604,7 +1607,7 @@ static const struct drm_output_funcs intel_tv_output_funcs = {
.mode_valid = intel_tv_mode_valid, .mode_valid = intel_tv_mode_valid,
.detect = intel_tv_detect, .detect = intel_tv_detect,
.get_modes = intel_tv_get_modes, .get_modes = intel_tv_get_modes,
.cleanup = intel_tv_destroy, .destroy = intel_tv_destroy,
.set_property = intel_tv_set_property, .set_property = intel_tv_set_property,
}; };
@ -1649,18 +1652,15 @@ intel_tv_init(struct drm_device *dev)
(tv_dac_off & TVDAC_STATE_CHG_EN) != 0) (tv_dac_off & TVDAC_STATE_CHG_EN) != 0)
return; return;
output = drm_output_create(dev, &intel_tv_output_funcs,
DRM_MODE_OUTPUT_TVDAC);
if (!output)
return;
intel_output = drm_calloc(1, sizeof(struct intel_output) + intel_output = drm_calloc(1, sizeof(struct intel_output) +
sizeof(struct intel_tv_priv), DRM_MEM_DRIVER); sizeof(struct intel_tv_priv), DRM_MEM_DRIVER);
if (!intel_output) { if (!intel_output) {
drm_output_destroy(output);
return; return;
} }
output = &intel_output->base;
drm_output_init(dev, output, &intel_tv_output_funcs,
DRM_MODE_OUTPUT_TVDAC);
tv_priv = (struct intel_tv_priv *)(intel_output + 1); tv_priv = (struct intel_tv_priv *)(intel_output + 1);
intel_output->type = INTEL_OUTPUT_TVOUT; intel_output->type = INTEL_OUTPUT_TVOUT;
@ -1678,7 +1678,6 @@ intel_tv_init(struct drm_device *dev)
tv_priv->tv_format = kstrdup(tv_modes[initial_mode].name, GFP_KERNEL); tv_priv->tv_format = kstrdup(tv_modes[initial_mode].name, GFP_KERNEL);
drm_output_helper_add(output, &intel_tv_helper_funcs); drm_output_helper_add(output, &intel_tv_helper_funcs);
output->driver_private = intel_output;
output->interlace_allowed = FALSE; output->interlace_allowed = FALSE;
output->doublescan_allowed = FALSE; output->doublescan_allowed = FALSE;

View File

@ -461,7 +461,7 @@ static void i915_hotplug_tv(struct drm_device *dev)
/* find the crt output */ /* find the crt output */
list_for_each_entry(output, &dev->mode_config.output_list, head) { list_for_each_entry(output, &dev->mode_config.output_list, head) {
iout = output->driver_private; iout = to_intel_output(output);
if (iout->type == INTEL_OUTPUT_TVOUT) if (iout->type == INTEL_OUTPUT_TVOUT)
break; break;
else else
@ -488,7 +488,7 @@ static void i915_hotplug_crt(struct drm_device *dev, bool isconnected)
/* find the crt output */ /* find the crt output */
list_for_each_entry(output, &dev->mode_config.output_list, head) { list_for_each_entry(output, &dev->mode_config.output_list, head) {
iout = output->driver_private; iout = to_intel_output(output);
if (iout->type == INTEL_OUTPUT_ANALOG) if (iout->type == INTEL_OUTPUT_ANALOG)
break; break;
else else