From 52f9028c84baea81230dc673b756552e8e90aecd Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 5 Apr 2007 11:21:06 +1000 Subject: Initial import of modesetting for intel driver in DRM --- linux-core/intel_crt.c | 226 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 linux-core/intel_crt.c (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c new file mode 100644 index 00000000..5ff9f791 --- /dev/null +++ b/linux-core/intel_crt.c @@ -0,0 +1,226 @@ +#include +#include "drmP.h" +#include "drm.h" +#include "drm_crtc.h" +#include "intel_drv.h" +#include "i915_drm.h" +#include "i915_drv.h" + +static void intel_crt_dpms(struct drm_output *output, int mode) +{ + drm_device_t *dev = output->dev; + drm_i915_private_t *dev_priv = dev->dev_private; + u32 temp; + + temp = I915_READ(ADPA); + temp &= ~(ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE); + temp &= ~ADPA_DAC_ENABLE; + + switch(mode) { + case DPMSModeOn: + temp |= ADPA_DAC_ENABLE; + break; + case DPMSModeStandby: + temp |= ADPA_DAC_ENABLE | ADPA_HSYNC_CNTL_DISABLE; + break; + case DPMSModeSuspend: + temp |= ADPA_DAC_ENABLE | ADPA_VSYNC_CNTL_DISABLE; + break; + case DPMSModeOff: + temp |= ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE; + break; + } + + I915_WRITE(ADPA, temp); +} + +static void intel_crt_save(struct drm_output *output) +{ + +} + +static void intel_crt_restore(struct drm_output *output) +{ + +} + +static int intel_crt_mode_valid(struct drm_output *output, + struct drm_display_mode *mode) +{ + if (mode->flags & V_DBLSCAN) + return MODE_NO_DBLESCAN; + + if (mode->clock > 400000 || mode->clock < 25000) + return MODE_CLOCK_RANGE; + + return MODE_OK; +} + +static bool intel_crt_mode_fixup(struct drm_output *output, + struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + return true; +} + +static void intel_crt_mode_set(struct drm_output *output, + struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + drm_device_t *dev = output->dev; + struct drm_crtc *crtc = output->crtc; + struct intel_crtc *intel_crtc = crtc->driver_private; + drm_i915_private_t *dev_priv = dev->dev_private; + int dpll_md_reg; + u32 adpa, dpll_md; + + if (intel_crtc->pipe == 0) + dpll_md_reg = DPLL_A_MD; + else + dpll_md_reg = DPLL_B_MD; + + /* + * Disable separate mode multiplier used when cloning SDVO to CRT + * XXX this needs to be adjusted when we really are cloning + */ + if (IS_I965G(dev)) + { + dpll_md = I915_READ(dpll_md_reg); + I915_WRITE(dpll_md_reg, dpll_md & ~DPLL_MD_UDI_MULTIPLIER_MASK); + } + + adpa = 0; + if (adjusted_mode->flags & V_PHSYNC) + adpa |= ADPA_HSYNC_ACTIVE_HIGH; + if (adjusted_mode->flags & V_PVSYNC) + adpa |= ADPA_VSYNC_ACTIVE_HIGH; + + if (intel_crtc->pipe == 0) + adpa |= ADPA_PIPE_A_SELECT; + else + adpa |= ADPA_PIPE_B_SELECT; + + I915_WRITE(ADPA, adpa); +} + +/** + * Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect CRT presence. + * + * Only for I945G/GM. + * + * \return TRUE if CRT is connected. + * \return FALSE if CRT is disconnected. + */ +static bool intel_crt_detect_hotplug(struct drm_output *output) +{ + drm_device_t *dev = output->dev; +// struct intel_output *intel_output = output->driver_private; + drm_i915_private_t *dev_priv = dev->dev_private; + u32 temp; + const int timeout_ms = 1000; + int starttime, curtime; + + temp = I915_READ(PORT_HOTPLUG_EN); + + I915_WRITE(PORT_HOTPLUG_EN, temp | CRT_HOTPLUG_FORCE_DETECT | (1 << 5)); +#if 0 + for (curtime = starttime = GetTimeInMillis(); + (curtime - starttime) < timeout_ms; curtime = GetTimeInMillis()) + { + if ((I915_READ(PORT_HOTPLUG_EN) & CRT_HOTPLUG_FORCE_DETECT) == 0) + break; + } +#endif + if ((I915_READ(PORT_HOTPLUG_STAT) & CRT_HOTPLUG_MONITOR_MASK) == + CRT_HOTPLUG_MONITOR_COLOR) + { + return true; + } else { + return false; + } +} + +static bool intel_crt_detect_ddc(struct drm_output *output) +{ + struct intel_output *intel_output = output->driver_private; + + /* CRT should always be at 0, but check anyway */ + if (intel_output->type != INTEL_OUTPUT_ANALOG) + return false; + + return intel_ddc_probe(output); +} + +static enum drm_output_status intel_crt_detect(struct drm_output *output) +{ + drm_device_t *dev = output->dev; + drm_i915_private_t *dev_priv = dev->dev_private; + + if (IS_I945G(dev)| IS_I945GM(dev) || IS_I965G(dev)) { + if (intel_crt_detect_hotplug(output)) + return output_status_connected; + else + return output_status_disconnected; + } + + if (intel_crt_detect_ddc(output)) + return output_status_connected; + + /* TODO use load detect */ + return output_status_unknown; +} + +static void intel_crt_destroy(struct drm_output *output) +{ + struct intel_output *intel_output = output->driver_private; + + intel_i2c_destroy(intel_output->ddc_bus); + + if (output->driver_private) + kfree(output->driver_private); +} + +/* + * Routines for controlling stuff on the analog port + */ +static const struct drm_output_funcs intel_crt_output_funcs = { + .dpms = intel_crt_dpms, + .save = intel_crt_save, + .restore = intel_crt_restore, + .mode_valid = intel_crt_mode_valid, + .mode_fixup = intel_crt_mode_fixup, + .prepare = intel_output_prepare, + .mode_set = intel_crt_mode_set, + .commit = intel_output_commit, + .detect = intel_crt_detect, + .get_modes = intel_ddc_get_modes, + .cleanup = intel_crt_destroy, +}; + +void intel_crt_init(drm_device_t *dev) +{ + struct drm_output *output; + struct intel_output *intel_output; + int modes; + + output = drm_output_create (dev, &intel_crt_output_funcs, "VGA"); + + intel_output = kmalloc(sizeof(struct intel_output), GFP_KERNEL); + if (!intel_output) { + drm_output_destroy(output); + return; + } + + intel_output->type = INTEL_OUTPUT_ANALOG; + output->driver_private = intel_output; + output->interlace_allowed = 0; + output->doublescan_allowed = 0; + + /* Set up the DDC bus. */ + intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); + if (!intel_output->ddc_bus) { + dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " + "failed.\n"); + return; + } +} -- cgit v1.2.3 From 6f3534a13abb0c8afb157511d0871dbc35bc403d Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Thu, 5 Apr 2007 09:21:31 -0700 Subject: Add copyrights before I forget --- linux-core/intel_crt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 5ff9f791..a251d986 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2006-2007 Intel Corporation + * Eric Anholt + */ + #include #include "drmP.h" #include "drm.h" -- cgit v1.2.3 From 1c9ba24c2f37ca78965f8aa57ece02ef5bdb9b06 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 5 Apr 2007 11:34:11 -0700 Subject: Add required permission notices for code copied from X.Org source. --- linux-core/intel_crt.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index a251d986..55d987a6 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -1,6 +1,27 @@ /* - * Copyright (c) 2006-2007 Intel Corporation - * Eric Anholt + * Copyright © 2006-2007 Intel Corporation + * + * 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 (including the next + * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Authors: + * Eric Anholt */ #include -- cgit v1.2.3 From 2430d0c3157ef20a3319a4f93dc44b28d0189868 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Sat, 7 Apr 2007 19:25:25 -0700 Subject: just codingstyle cleanups --- linux-core/intel_crt.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 55d987a6..e62aa8d3 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -109,10 +109,10 @@ static void intel_crt_mode_set(struct drm_output *output, * Disable separate mode multiplier used when cloning SDVO to CRT * XXX this needs to be adjusted when we really are cloning */ - if (IS_I965G(dev)) - { + if (IS_I965G(dev)) { dpll_md = I915_READ(dpll_md_reg); - I915_WRITE(dpll_md_reg, dpll_md & ~DPLL_MD_UDI_MULTIPLIER_MASK); + I915_WRITE(dpll_md_reg, + dpll_md & ~DPLL_MD_UDI_MULTIPLIER_MASK); } adpa = 0; @@ -143,8 +143,8 @@ static bool intel_crt_detect_hotplug(struct drm_output *output) // struct intel_output *intel_output = output->driver_private; drm_i915_private_t *dev_priv = dev->dev_private; u32 temp; - const int timeout_ms = 1000; - int starttime, curtime; +// const int timeout_ms = 1000; +// int starttime, curtime; temp = I915_READ(PORT_HOTPLUG_EN); @@ -180,7 +180,6 @@ static bool intel_crt_detect_ddc(struct drm_output *output) static enum drm_output_status intel_crt_detect(struct drm_output *output) { drm_device_t *dev = output->dev; - drm_i915_private_t *dev_priv = dev->dev_private; if (IS_I945G(dev)| IS_I945GM(dev) || IS_I965G(dev)) { if (intel_crt_detect_hotplug(output)) @@ -227,9 +226,8 @@ void intel_crt_init(drm_device_t *dev) { struct drm_output *output; struct intel_output *intel_output; - int modes; - output = drm_output_create (dev, &intel_crt_output_funcs, "VGA"); + output = drm_output_create(dev, &intel_crt_output_funcs, "VGA"); intel_output = kmalloc(sizeof(struct intel_output), GFP_KERNEL); if (!intel_output) { -- cgit v1.2.3 From f35db6690625ccd01fb61dc766e6380a9c14c331 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Wed, 11 Apr 2007 07:08:29 -0700 Subject: Fixup DDC probing. We only have one DDC bus so we have to use it only on demand, and unregister when we're done. --- linux-core/intel_crt.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index e62aa8d3..ca7ae7b3 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -180,6 +180,7 @@ static bool intel_crt_detect_ddc(struct drm_output *output) static enum drm_output_status intel_crt_detect(struct drm_output *output) { drm_device_t *dev = output->dev; + struct intel_output *intel_output = output->driver_private; if (IS_I945G(dev)| IS_I945GM(dev) || IS_I965G(dev)) { if (intel_crt_detect_hotplug(output)) @@ -188,21 +189,47 @@ static enum drm_output_status intel_crt_detect(struct drm_output *output) return output_status_disconnected; } - if (intel_crt_detect_ddc(output)) + /* Set up the DDC bus. */ + intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); + if (!intel_output->ddc_bus) { + dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " + "failed.\n"); + return 0; + } + + if (intel_crt_detect_ddc(output)) { + intel_i2c_destroy(intel_output->ddc_bus); return output_status_connected; + } + intel_i2c_destroy(intel_output->ddc_bus); /* TODO use load detect */ return output_status_unknown; } static void intel_crt_destroy(struct drm_output *output) { + if (output->driver_private) + kfree(output->driver_private); +} + +static int intel_crt_get_modes(struct drm_output *output) +{ + struct drm_device *dev = output->dev; struct intel_output *intel_output = output->driver_private; + int ret; - intel_i2c_destroy(intel_output->ddc_bus); + /* Set up the DDC bus. */ + intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); + if (!intel_output->ddc_bus) { + dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " + "failed.\n"); + return 0; + } - if (output->driver_private) - kfree(output->driver_private); + ret = intel_ddc_get_modes(output); + intel_i2c_destroy(intel_output->ddc_bus); + return ret; } /* @@ -218,7 +245,7 @@ static const struct drm_output_funcs intel_crt_output_funcs = { .mode_set = intel_crt_mode_set, .commit = intel_output_commit, .detect = intel_crt_detect, - .get_modes = intel_ddc_get_modes, + .get_modes = intel_crt_get_modes, .cleanup = intel_crt_destroy, }; @@ -239,12 +266,4 @@ void intel_crt_init(drm_device_t *dev) output->driver_private = intel_output; output->interlace_allowed = 0; output->doublescan_allowed = 0; - - /* Set up the DDC bus. */ - intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); - if (!intel_output->ddc_bus) { - dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " - "failed.\n"); - return; - } } -- cgit v1.2.3 From c2fce380c26d72f2d7971a4d08076da33c41f5ae Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Thu, 12 Apr 2007 08:57:58 -0700 Subject: Move i2c init back to where it belongs and add i2c unregistration in *_destroy. --- linux-core/intel_crt.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index ca7ae7b3..fe846eb8 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -189,26 +189,19 @@ static enum drm_output_status intel_crt_detect(struct drm_output *output) return output_status_disconnected; } - /* Set up the DDC bus. */ - intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); - if (!intel_output->ddc_bus) { - dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " - "failed.\n"); - return 0; - } - - if (intel_crt_detect_ddc(output)) { - intel_i2c_destroy(intel_output->ddc_bus); + if (intel_crt_detect_ddc(output)) return output_status_connected; - } - intel_i2c_destroy(intel_output->ddc_bus); /* TODO use load detect */ return output_status_unknown; } static void intel_crt_destroy(struct drm_output *output) { + struct intel_output *intel_output = output->driver_private; + + intel_i2c_destroy(intel_output->ddc_bus); + if (output->driver_private) kfree(output->driver_private); } @@ -219,17 +212,7 @@ static int intel_crt_get_modes(struct drm_output *output) struct intel_output *intel_output = output->driver_private; int ret; - /* Set up the DDC bus. */ - intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); - if (!intel_output->ddc_bus) { - dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " - "failed.\n"); - return 0; - } - - ret = intel_ddc_get_modes(output); - intel_i2c_destroy(intel_output->ddc_bus); - return ret; + return intel_ddc_get_modes(output); } /* @@ -261,6 +244,13 @@ void intel_crt_init(drm_device_t *dev) drm_output_destroy(output); return; } + /* Set up the DDC bus. */ + intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); + if (!intel_output->ddc_bus) { + dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " + "failed.\n"); + return; + } intel_output->type = INTEL_OUTPUT_ANALOG; output->driver_private = intel_output; -- cgit v1.2.3 From fb3c82f1d8362a0b7d64cb3bce75be8c72328e1c Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Thu, 12 Apr 2007 11:50:57 -0700 Subject: Don't need a NULL check prior to calling kfree. --- linux-core/intel_crt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index fe846eb8..ebf6e469 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -201,9 +201,7 @@ static void intel_crt_destroy(struct drm_output *output) struct intel_output *intel_output = output->driver_private; intel_i2c_destroy(intel_output->ddc_bus); - - if (output->driver_private) - kfree(output->driver_private); + kfree(output->driver_private); } static int intel_crt_get_modes(struct drm_output *output) -- cgit v1.2.3 From 9e5d61d5b8c052b4dc126b155dca1f0d2e4e5ad9 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Thu, 12 Apr 2007 12:40:51 -0700 Subject: Fix 945+ hotplug detection, remove some unused variables. --- linux-core/intel_crt.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index ebf6e469..86eaff54 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -140,30 +140,25 @@ static void intel_crt_mode_set(struct drm_output *output, static bool intel_crt_detect_hotplug(struct drm_output *output) { drm_device_t *dev = output->dev; -// struct intel_output *intel_output = output->driver_private; drm_i915_private_t *dev_priv = dev->dev_private; u32 temp; -// const int timeout_ms = 1000; -// int starttime, curtime; + unsigned long timeout = jiffies + msecs_to_jiffies(1000); temp = I915_READ(PORT_HOTPLUG_EN); - I915_WRITE(PORT_HOTPLUG_EN, temp | CRT_HOTPLUG_FORCE_DETECT | (1 << 5)); -#if 0 - for (curtime = starttime = GetTimeInMillis(); - (curtime - starttime) < timeout_ms; curtime = GetTimeInMillis()) - { - if ((I915_READ(PORT_HOTPLUG_EN) & CRT_HOTPLUG_FORCE_DETECT) == 0) + I915_WRITE(PORT_HOTPLUG_EN, + temp | CRT_HOTPLUG_FORCE_DETECT | (1 << 5)); + + do { + if (!(I915_READ(PORT_HOTPLUG_EN) & CRT_HOTPLUG_FORCE_DETECT)) break; - } -#endif + } while (time_after(timeout, jiffies)); + if ((I915_READ(PORT_HOTPLUG_STAT) & CRT_HOTPLUG_MONITOR_MASK) == CRT_HOTPLUG_MONITOR_COLOR) - { return true; - } else { - return false; - } + + return false; } static bool intel_crt_detect_ddc(struct drm_output *output) @@ -180,7 +175,6 @@ static bool intel_crt_detect_ddc(struct drm_output *output) static enum drm_output_status intel_crt_detect(struct drm_output *output) { drm_device_t *dev = output->dev; - struct intel_output *intel_output = output->driver_private; if (IS_I945G(dev)| IS_I945GM(dev) || IS_I965G(dev)) { if (intel_crt_detect_hotplug(output)) @@ -206,10 +200,6 @@ static void intel_crt_destroy(struct drm_output *output) static int intel_crt_get_modes(struct drm_output *output) { - struct drm_device *dev = output->dev; - struct intel_output *intel_output = output->driver_private; - int ret; - return intel_ddc_get_modes(output); } -- cgit v1.2.3 From 79b7a588bb685459d51527e7ac6877696fe392a3 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Thu, 12 Apr 2007 14:57:07 -0700 Subject: Oops, forgot to push the msleep() in the hotplug test. Wouldn't want to spin in the kernel for a whole second w/o it... --- linux-core/intel_crt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 86eaff54..cdfb314f 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -152,6 +152,7 @@ static bool intel_crt_detect_hotplug(struct drm_output *output) do { if (!(I915_READ(PORT_HOTPLUG_EN) & CRT_HOTPLUG_FORCE_DETECT)) break; + msleep(1); } while (time_after(timeout, jiffies)); if ((I915_READ(PORT_HOTPLUG_STAT) & CRT_HOTPLUG_MONITOR_MASK) == -- cgit v1.2.3 From 12cbe1365b38ae04ad4979123eb5b4e9538ee533 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 15 Nov 2007 16:51:35 +1100 Subject: intel: fixup || vs | --- linux-core/intel_crt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index d2e1f95c..29c2e611 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -177,7 +177,7 @@ static enum drm_output_status intel_crt_detect(struct drm_output *output) { struct drm_device *dev = output->dev; - if (IS_I945G(dev)| IS_I945GM(dev) || IS_I965G(dev)) { + if (IS_I945G(dev) || IS_I945GM(dev) || IS_I965G(dev)) { if (intel_crt_detect_hotplug(output)) return output_status_connected; else -- cgit v1.2.3 From 1a6c95ef711fce807659ab5e4fe480d65ac233b6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 5 Dec 2007 16:03:05 +1000 Subject: arrgggh.. make all ioctl structs 32/64-bit compatible hopefully. This also starts to add blob property support. someone needs to check this work for other things like ppc/x86 alignment diffs --- linux-core/intel_crt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 29c2e611..d3ad4654 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -245,4 +245,6 @@ void intel_crt_init(struct drm_device *dev) output->driver_private = intel_output; output->interlace_allowed = 0; output->doublescan_allowed = 0; + + drm_output_attach_property(output, dev->mode_config.edid_property, 0); } -- cgit v1.2.3 From 67f6eb1eb8d3dc5bb5fdb097655d3da326f637c1 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 6 Dec 2007 10:44:51 +1000 Subject: add property blobs and edid reporting support --- linux-core/intel_crt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index d3ad4654..2ab6a27b 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -246,5 +246,4 @@ void intel_crt_init(struct drm_device *dev) output->interlace_allowed = 0; output->doublescan_allowed = 0; - drm_output_attach_property(output, dev->mode_config.edid_property, 0); } -- cgit v1.2.3 From f99dea7db00dd46aa96eaed3a61dff9c956fd86f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 11 Dec 2007 15:56:48 +1000 Subject: modesetting: fixup property setting and add connector property --- linux-core/intel_crt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 2ab6a27b..722a62c8 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -204,6 +204,19 @@ static int intel_crt_get_modes(struct drm_output *output) return intel_ddc_get_modes(output); } +static bool intel_crt_set_property(struct drm_output *output, + struct drm_property *property, + uint64_t value) +{ + struct drm_device *dev = output->dev; + int i; + + if (property == dev->mode_config.dpms_property) { + intel_crt_dpms(output, (uint32_t)(value & 0xf)); + } + return true; +} + /* * Routines for controlling stuff on the analog port */ @@ -219,6 +232,7 @@ static const struct drm_output_funcs intel_crt_output_funcs = { .detect = intel_crt_detect, .get_modes = intel_crt_get_modes, .cleanup = intel_crt_destroy, + .set_property = intel_crt_set_property, }; void intel_crt_init(struct drm_device *dev) @@ -246,4 +260,5 @@ void intel_crt_init(struct drm_device *dev) output->interlace_allowed = 0; output->doublescan_allowed = 0; + drm_output_attach_property(output, dev->mode_config.connector_type_property, ConnectorVGA); } -- cgit v1.2.3 From e239882b1e90cba0297118ec7dc432bea06b0bd0 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 4 Dec 2007 15:36:36 +0100 Subject: Modesetting Hotplug --- linux-core/intel_crt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 722a62c8..864b1a25 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -142,6 +142,7 @@ static bool intel_crt_detect_hotplug(struct drm_output *output) struct drm_device *dev = output->dev; struct drm_i915_private *dev_priv = dev->dev_private; u32 temp; +#if 1 unsigned long timeout = jiffies + msecs_to_jiffies(1000); temp = I915_READ(PORT_HOTPLUG_EN); @@ -160,6 +161,15 @@ static bool intel_crt_detect_hotplug(struct drm_output *output) return true; return false; +#else + temp = I915_READ(PORT_HOTPLUG_STAT); + DRM_DEBUG("HST 0x%08x\n", temp); + + if (temp & (1 << 8) && temp & (1 << 9)) + return true; + + return false; +#endif } static bool intel_crt_detect_ddc(struct drm_output *output) -- cgit v1.2.3 From b13dc383df85d75cb1ea422f4d13efc2a4a8a732 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 18 Dec 2007 17:41:20 +1100 Subject: remove output names --- linux-core/intel_crt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 722a62c8..74e3dcd6 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -240,7 +240,8 @@ void intel_crt_init(struct drm_device *dev) struct drm_output *output; struct intel_output *intel_output; - output = drm_output_create(dev, &intel_crt_output_funcs, "VGA"); + output = drm_output_create(dev, &intel_crt_output_funcs, + DRM_MODE_OUTPUT_DAC); intel_output = kmalloc(sizeof(struct intel_output), GFP_KERNEL); if (!intel_output) { -- cgit v1.2.3 From de0084590bc34c2c23cb3d7a754f3e98059f4cf2 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 5 Feb 2008 10:11:46 +0000 Subject: fix some warnings --- linux-core/intel_crt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 4be71cba..a9fb50a3 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -219,11 +219,10 @@ static bool intel_crt_set_property(struct drm_output *output, uint64_t value) { struct drm_device *dev = output->dev; - int i; - if (property == dev->mode_config.dpms_property) { + if (property == dev->mode_config.dpms_property) intel_crt_dpms(output, (uint32_t)(value & 0xf)); - } + return true; } -- cgit v1.2.3 From 903d9231d6f998657cc80ee6f20ded4df68e691b Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 11 Mar 2008 20:29:37 +0000 Subject: Add support for monitor hotplug signals/waits Also adjust i915 irq handling as it follows the 16bit'ism's of the i8xx series. --- linux-core/intel_crt.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index a9fb50a3..915e430d 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -132,7 +132,7 @@ static void intel_crt_mode_set(struct drm_output *output, /** * Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect CRT presence. * - * Only for I945G/GM. + * Not for i915G/i915GM * * \return TRUE if CRT is connected. * \return FALSE if CRT is disconnected. @@ -142,7 +142,7 @@ static bool intel_crt_detect_hotplug(struct drm_output *output) struct drm_device *dev = output->dev; struct drm_i915_private *dev_priv = dev->dev_private; u32 temp; -#if 1 + unsigned long timeout = jiffies + msecs_to_jiffies(1000); temp = I915_READ(PORT_HOTPLUG_EN); @@ -161,15 +161,6 @@ static bool intel_crt_detect_hotplug(struct drm_output *output) return true; return false; -#else - temp = I915_READ(PORT_HOTPLUG_STAT); - DRM_DEBUG("HST 0x%08x\n", temp); - - if (temp & (1 << 8) && temp & (1 << 9)) - return true; - - return false; -#endif } static bool intel_crt_detect_ddc(struct drm_output *output) @@ -187,7 +178,7 @@ static enum drm_output_status intel_crt_detect(struct drm_output *output) { struct drm_device *dev = output->dev; - if (IS_I945G(dev) || IS_I945GM(dev) || IS_I965G(dev)) { + if (IS_I9XX(dev) && !IS_I915G(dev) && !IS_I915GM(dev)) { if (intel_crt_detect_hotplug(output)) return output_status_connected; else -- cgit v1.2.3 From fa116081a919e716eb95fcfa421d93f10f6f0a4f Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Wed, 9 Apr 2008 11:30:15 -0700 Subject: Fixup sysfs output registration Put off registering new outputs with sysfs until they're properly configured, or we may get duplicates if the type hasn't been set yet (as is the case with SDVO initialization). This also means moving de-registration into the cleanup function instead of output destroy, since the latter occurs during the normal course of setup when an output isn't found (and therefore not registered with sysfs yet. --- linux-core/intel_crt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 915e430d..ef40871e 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -261,5 +261,7 @@ void intel_crt_init(struct drm_device *dev) output->interlace_allowed = 0; output->doublescan_allowed = 0; + drm_sysfs_output_add(output); + drm_output_attach_property(output, dev->mode_config.connector_type_property, ConnectorVGA); } -- cgit v1.2.3 From df8cd54286fbae5903d8ede390ec4a11cb6c4b6c Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 29 May 2008 14:02:14 +1000 Subject: modesetting: reorganise code into core and helper functions. This splits a lot of the core modesetting code out into a file of helper functions, that are only called from themselves and/or the driver. The driver gets called into more often or can call these functions from itself if it is a helper using driver. I've broken framebuffer resize doing this but I didn't like the API for that in any case. --- linux-core/intel_crt.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index ef40871e..3c5dae1a 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -28,6 +28,7 @@ #include "drmP.h" #include "drm.h" #include "drm_crtc.h" +#include "drm_crtc_helper.h" #include "intel_drv.h" #include "i915_drm.h" #include "i915_drv.h" @@ -220,19 +221,24 @@ static bool intel_crt_set_property(struct drm_output *output, /* * Routines for controlling stuff on the analog port */ + +static const struct drm_output_helper_funcs intel_crt_helper_funcs = { + .mode_fixup = intel_crt_mode_fixup, + .prepare = intel_output_prepare, + .commit = intel_output_commit, + .mode_set = intel_crt_mode_set, +}; + static const struct drm_output_funcs intel_crt_output_funcs = { .dpms = intel_crt_dpms, .save = intel_crt_save, .restore = intel_crt_restore, - .mode_valid = intel_crt_mode_valid, - .mode_fixup = intel_crt_mode_fixup, - .prepare = intel_output_prepare, - .mode_set = intel_crt_mode_set, - .commit = intel_output_commit, .detect = intel_crt_detect, .get_modes = intel_crt_get_modes, .cleanup = intel_crt_destroy, .set_property = intel_crt_set_property, + .mode_valid = intel_crt_mode_valid, + }; void intel_crt_init(struct drm_device *dev) @@ -261,6 +267,7 @@ void intel_crt_init(struct drm_device *dev) output->interlace_allowed = 0; output->doublescan_allowed = 0; + drm_output_helper_add(output, &intel_crt_helper_funcs); drm_sysfs_output_add(output); drm_output_attach_property(output, dev->mode_config.connector_type_property, ConnectorVGA); -- cgit v1.2.3 From 98c5cf7f6fc51f1a8f5f90b3895009cd38dd8f22 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 30 May 2008 11:25:41 +1000 Subject: 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. --- linux-core/intel_crt.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 3c5dae1a..584dea21 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -96,7 +96,7 @@ static void intel_crt_mode_set(struct drm_output *output, { struct drm_device *dev = output->dev; 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; int dpll_md_reg; 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) { - 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 */ 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) { - struct intel_output *intel_output = output->driver_private; + struct intel_output *intel_output = to_intel_output(output); 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) @@ -235,7 +236,7 @@ static const struct drm_output_funcs intel_crt_output_funcs = { .restore = intel_crt_restore, .detect = intel_crt_detect, .get_modes = intel_crt_get_modes, - .cleanup = intel_crt_destroy, + .destroy = intel_crt_destroy, .set_property = intel_crt_set_property, .mode_valid = intel_crt_mode_valid, @@ -246,24 +247,23 @@ void intel_crt_init(struct drm_device *dev) struct drm_output *output; struct intel_output *intel_output; - output = drm_output_create(dev, &intel_crt_output_funcs, - DRM_MODE_OUTPUT_DAC); - - intel_output = kmalloc(sizeof(struct intel_output), GFP_KERNEL); - if (!intel_output) { - drm_output_destroy(output); + intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); + if (!intel_output) 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. */ intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); if (!intel_output->ddc_bus) { dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " "failed.\n"); + intel_crt_destroy(output); return; } intel_output->type = INTEL_OUTPUT_ANALOG; - output->driver_private = intel_output; output->interlace_allowed = 0; output->doublescan_allowed = 0; -- cgit v1.2.3 From 6aeef92c0cad784a5019ea90d97ab81f4e51fdd9 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 30 May 2008 13:57:27 +1000 Subject: drm: attach an encoder. Time to do some renaming on the connectors I think --- linux-core/intel_crt.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 584dea21..44035783 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -242,6 +242,15 @@ static const struct drm_output_funcs intel_crt_output_funcs = { }; +void intel_crt_enc_destroy(struct drm_encoder *encoder) +{ + drm_encoder_cleanup(encoder); +} + +static const struct drm_encoder_funcs intel_crt_enc_funcs = { + .destroy = intel_crt_enc_destroy, +}; + void intel_crt_init(struct drm_device *dev) { struct drm_output *output; @@ -252,7 +261,11 @@ void intel_crt_init(struct drm_device *dev) return; output = &intel_output->base; - drm_output_init(dev, &intel_output->base, &intel_crt_output_funcs, DRM_MODE_OUTPUT_DAC); + drm_output_init(dev, &intel_output->base, &intel_crt_output_funcs, DRM_MODE_OUTPUT_VGA); + + drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs, DRM_MODE_ENCODER_DAC); + + drm_mode_output_attach_encoder(&intel_output->base, &intel_output->enc); /* Set up the DDC bus. */ intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); @@ -268,7 +281,6 @@ void intel_crt_init(struct drm_device *dev) output->doublescan_allowed = 0; drm_output_helper_add(output, &intel_crt_helper_funcs); - drm_sysfs_output_add(output); - drm_output_attach_property(output, dev->mode_config.connector_type_property, ConnectorVGA); + drm_sysfs_output_add(output); } -- cgit v1.2.3 From 9d38448ed33aaff324cc4bbe1e0878593e97d07d Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 30 May 2008 15:03:12 +1000 Subject: modesetting: the great renaming. Okay we have crtc, encoder and connectors. No more outputs exposed beyond driver internals I've broken intel tv connector stuff. Really for TV we should have one TV connector, with a sub property for the type of signal been driven over it --- linux-core/intel_crt.c | 91 ++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 44 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 44035783..a98f7000 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -33,9 +33,9 @@ #include "i915_drm.h" #include "i915_drv.h" -static void intel_crt_dpms(struct drm_output *output, int mode) +static void intel_crt_dpms(struct drm_connector *connector, int mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; u32 temp; @@ -61,17 +61,17 @@ static void intel_crt_dpms(struct drm_output *output, int mode) I915_WRITE(ADPA, temp); } -static void intel_crt_save(struct drm_output *output) +static void intel_crt_save(struct drm_connector *connector) { } -static void intel_crt_restore(struct drm_output *output) +static void intel_crt_restore(struct drm_connector *connector) { } -static int intel_crt_mode_valid(struct drm_output *output, +static int intel_crt_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { if (mode->flags & V_DBLSCAN) @@ -83,19 +83,19 @@ static int intel_crt_mode_valid(struct drm_output *output, return MODE_OK; } -static bool intel_crt_mode_fixup(struct drm_output *output, +static bool intel_crt_mode_fixup(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { return true; } -static void intel_crt_mode_set(struct drm_output *output, +static void intel_crt_mode_set(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct drm_device *dev = output->dev; - struct drm_crtc *crtc = output->crtc; + struct drm_device *dev = connector->dev; + struct drm_crtc *crtc = connector->crtc; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct drm_i915_private *dev_priv = dev->dev_private; int dpll_md_reg; @@ -138,9 +138,9 @@ static void intel_crt_mode_set(struct drm_output *output, * \return TRUE if CRT is connected. * \return FALSE if CRT is disconnected. */ -static bool intel_crt_detect_hotplug(struct drm_output *output) +static bool intel_crt_detect_hotplug(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; u32 temp; @@ -164,57 +164,58 @@ static bool intel_crt_detect_hotplug(struct drm_output *output) return false; } -static bool intel_crt_detect_ddc(struct drm_output *output) +static bool intel_crt_detect_ddc(struct drm_connector *connector) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); /* CRT should always be at 0, but check anyway */ if (intel_output->type != INTEL_OUTPUT_ANALOG) return false; - return intel_ddc_probe(output); + return intel_ddc_probe(intel_output); } -static enum drm_output_status intel_crt_detect(struct drm_output *output) +static enum drm_connector_status intel_crt_detect(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; if (IS_I9XX(dev) && !IS_I915G(dev) && !IS_I915GM(dev)) { - if (intel_crt_detect_hotplug(output)) - return output_status_connected; + if (intel_crt_detect_hotplug(connector)) + return connector_status_connected; else - return output_status_disconnected; + return connector_status_disconnected; } - if (intel_crt_detect_ddc(output)) - return output_status_connected; + if (intel_crt_detect_ddc(connector)) + return connector_status_connected; /* TODO use load detect */ - return output_status_unknown; + return connector_status_unknown; } -static void intel_crt_destroy(struct drm_output *output) +static void intel_crt_destroy(struct drm_connector *connector) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); intel_i2c_destroy(intel_output->ddc_bus); - drm_output_cleanup(output); - kfree(output); + drm_connector_cleanup(connector); + kfree(connector); } -static int intel_crt_get_modes(struct drm_output *output) +static int intel_crt_get_modes(struct drm_connector *connector) { - return intel_ddc_get_modes(output); + struct intel_output *intel_output = to_intel_output(connector); + return intel_ddc_get_modes(intel_output); } -static bool intel_crt_set_property(struct drm_output *output, +static bool intel_crt_set_property(struct drm_connector *connector, struct drm_property *property, uint64_t value) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; if (property == dev->mode_config.dpms_property) - intel_crt_dpms(output, (uint32_t)(value & 0xf)); + intel_crt_dpms(connector, (uint32_t)(value & 0xf)); return true; } @@ -223,14 +224,14 @@ static bool intel_crt_set_property(struct drm_output *output, * Routines for controlling stuff on the analog port */ -static const struct drm_output_helper_funcs intel_crt_helper_funcs = { +static const struct drm_connector_helper_funcs intel_crt_helper_funcs = { .mode_fixup = intel_crt_mode_fixup, - .prepare = intel_output_prepare, - .commit = intel_output_commit, + .prepare = intel_connector_prepare, + .commit = intel_connector_commit, .mode_set = intel_crt_mode_set, }; -static const struct drm_output_funcs intel_crt_output_funcs = { +static const struct drm_connector_funcs intel_crt_connector_funcs = { .dpms = intel_crt_dpms, .save = intel_crt_save, .restore = intel_crt_restore, @@ -253,34 +254,36 @@ static const struct drm_encoder_funcs intel_crt_enc_funcs = { void intel_crt_init(struct drm_device *dev) { - struct drm_output *output; + struct drm_connector *connector; struct intel_output *intel_output; intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); if (!intel_output) return; - output = &intel_output->base; - drm_output_init(dev, &intel_output->base, &intel_crt_output_funcs, DRM_MODE_OUTPUT_VGA); + connector = &intel_output->base; + drm_connector_init(dev, &intel_output->base, &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs, DRM_MODE_ENCODER_DAC); - drm_mode_output_attach_encoder(&intel_output->base, &intel_output->enc); + drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); /* Set up the DDC bus. */ intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); if (!intel_output->ddc_bus) { dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " "failed.\n"); - intel_crt_destroy(output); + intel_crt_destroy(connector); return; } intel_output->type = INTEL_OUTPUT_ANALOG; - output->interlace_allowed = 0; - output->doublescan_allowed = 0; + connector->interlace_allowed = 0; + connector->doublescan_allowed = 0; + + drm_connector_helper_add(connector, &intel_crt_helper_funcs); + + drm_sysfs_connector_add(connector); - drm_output_helper_add(output, &intel_crt_helper_funcs); - drm_sysfs_output_add(output); } -- cgit v1.2.3 From e439e74776b215d70d8e34e8aa9cea22179dcbc6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 2 Jun 2008 10:05:54 +1000 Subject: drm/modesetting: another re-org of some internals. Move dpms into the helper functions. Move crtc into the encoder. Move disable unused functions into the helper. --- linux-core/intel_crt.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index a98f7000..ec4c2bf9 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -33,9 +33,9 @@ #include "i915_drm.h" #include "i915_drv.h" -static void intel_crt_dpms(struct drm_connector *connector, int mode) +static void intel_crt_dpms(struct drm_encoder *encoder, int mode) { - struct drm_device *dev = connector->dev; + struct drm_device *dev = encoder->dev; struct drm_i915_private *dev_priv = dev->dev_private; u32 temp; @@ -83,19 +83,20 @@ static int intel_crt_mode_valid(struct drm_connector *connector, return MODE_OK; } -static bool intel_crt_mode_fixup(struct drm_connector *connector, +static bool intel_crt_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { return true; } -static void intel_crt_mode_set(struct drm_connector *connector, +static void intel_crt_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct drm_device *dev = connector->dev; - struct drm_crtc *crtc = connector->crtc; + + struct drm_device *dev = encoder->dev; + struct drm_crtc *crtc = encoder->crtc; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct drm_i915_private *dev_priv = dev->dev_private; int dpll_md_reg; @@ -214,8 +215,8 @@ static bool intel_crt_set_property(struct drm_connector *connector, { struct drm_device *dev = connector->dev; - if (property == dev->mode_config.dpms_property) - intel_crt_dpms(connector, (uint32_t)(value & 0xf)); + if (property == dev->mode_config.dpms_property && connector->encoder) + intel_crt_dpms(connector->encoder, (uint32_t)(value & 0xf)); return true; } @@ -224,15 +225,15 @@ static bool intel_crt_set_property(struct drm_connector *connector, * Routines for controlling stuff on the analog port */ -static const struct drm_connector_helper_funcs intel_crt_helper_funcs = { +static const struct drm_encoder_helper_funcs intel_crt_helper_funcs = { + .dpms = intel_crt_dpms, .mode_fixup = intel_crt_mode_fixup, - .prepare = intel_connector_prepare, - .commit = intel_connector_commit, + .prepare = intel_encoder_prepare, + .commit = intel_encoder_commit, .mode_set = intel_crt_mode_set, }; static const struct drm_connector_funcs intel_crt_connector_funcs = { - .dpms = intel_crt_dpms, .save = intel_crt_save, .restore = intel_crt_restore, .detect = intel_crt_detect, @@ -281,7 +282,7 @@ void intel_crt_init(struct drm_device *dev) connector->interlace_allowed = 0; connector->doublescan_allowed = 0; - drm_connector_helper_add(connector, &intel_crt_helper_funcs); + drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs); drm_sysfs_connector_add(connector); -- cgit v1.2.3 From 0dd000b578adec6ff101c957bce7dc9a32b76713 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 2 Jun 2008 11:12:28 +1000 Subject: drm/modesetting: move some connector functions to helper. Migrated the output mode collection into the helper. --- linux-core/intel_crt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index ec4c2bf9..21a1e7d7 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -237,13 +237,16 @@ static const struct drm_connector_funcs intel_crt_connector_funcs = { .save = intel_crt_save, .restore = intel_crt_restore, .detect = intel_crt_detect, - .get_modes = intel_crt_get_modes, + .fill_modes = drm_helper_probe_single_connector_modes, .destroy = intel_crt_destroy, .set_property = intel_crt_set_property, - .mode_valid = intel_crt_mode_valid, - }; +static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs = { + .mode_valid = intel_crt_mode_valid, + .get_modes = intel_crt_get_modes, +}; + void intel_crt_enc_destroy(struct drm_encoder *encoder) { drm_encoder_cleanup(encoder); @@ -283,6 +286,7 @@ void intel_crt_init(struct drm_device *dev) connector->doublescan_allowed = 0; drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs); + drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs); drm_sysfs_connector_add(connector); -- cgit v1.2.3 From 46c78a2223802b9105a87b7125fd4872ab69c4ca Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 2 Jun 2008 11:44:35 +1000 Subject: drm/modesetting: add best encoder finding for modesetting This asks the driver to suggest the best encoder for the connector during the pick crtcs stage. Need to also do this during mode setting stages --- linux-core/intel_crt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 21a1e7d7..bf7c449e 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -245,6 +245,7 @@ static const struct drm_connector_funcs intel_crt_connector_funcs = { static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs = { .mode_valid = intel_crt_mode_valid, .get_modes = intel_crt_get_modes, + .best_encoder = intel_best_encoder, }; void intel_crt_enc_destroy(struct drm_encoder *encoder) -- cgit v1.2.3 From 58aca7485a4cd9fcccc6e4044325048abcc2f9c7 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 4 Jun 2008 13:03:23 +1000 Subject: drm: remove sysfs in driver for now.. should probably be in helper --- linux-core/intel_crt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index bf7c449e..e32a9551 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -199,6 +199,7 @@ static void intel_crt_destroy(struct drm_connector *connector) struct intel_output *intel_output = to_intel_output(connector); intel_i2c_destroy(intel_output->ddc_bus); + drm_sysfs_connector_remove(connector); drm_connector_cleanup(connector); kfree(connector); } -- cgit v1.2.3 From 03bf1fba67413f381d2a548fe08bd634a48fcc48 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Thu, 5 Jun 2008 15:58:43 -0700 Subject: sysfs registration/teardown fixups A check in drm_sysfs_connector_remove was supposed to allow it to be called even with unregistered objects, to make cleanup paths a little simpler. However, device_is_regsitered didn't always seem to return what we thought it would, so we'd sometimes end up leaving objects lying around rather than unregistering them. Fix this situation up by requiring devices to be registered before being removed. Any problems resulting from this change should be easier to track down than the alternative (which is leaving kobjects registered after unload). --- linux-core/intel_crt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index e32a9551..b9e8ee63 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -268,18 +268,20 @@ void intel_crt_init(struct drm_device *dev) return; connector = &intel_output->base; - drm_connector_init(dev, &intel_output->base, &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); + drm_connector_init(dev, &intel_output->base, + &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); - drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs, DRM_MODE_ENCODER_DAC); + drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs, + DRM_MODE_ENCODER_DAC); - drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); + drm_mode_connector_attach_encoder(&intel_output->base, + &intel_output->enc); /* Set up the DDC bus. */ intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); if (!intel_output->ddc_bus) { dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " "failed.\n"); - intel_crt_destroy(connector); return; } @@ -291,6 +293,4 @@ void intel_crt_init(struct drm_device *dev) drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs); drm_sysfs_connector_add(connector); - - } -- cgit v1.2.3 From 13943fe5823c45759091c1a1f487a4abe377421e Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Thu, 26 Jun 2008 21:28:29 +0200 Subject: modesetting-101: Make dpms property optional + misc cleanup. - intel_crt seems the only one to provide it, so init it there. --- linux-core/intel_crt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index b9e8ee63..c7509d5e 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -292,5 +292,9 @@ void intel_crt_init(struct drm_device *dev) drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs); drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs); + /* create dpms property */ + drm_mode_create_dpms_property(dev); + drm_connector_attach_property(connector, dev->mode_config.dpms_property, 0); + drm_sysfs_connector_add(connector); } -- cgit v1.2.3 From 087e3f577d795bcd007619514bb2977eede70c16 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Thu, 26 Jun 2008 23:12:04 +0200 Subject: Revert "modesetting-101: Make dpms property optional + misc cleanup." This reverts commit 13943fe5823c45759091c1a1f487a4abe377421e. --- linux-core/intel_crt.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index c7509d5e..b9e8ee63 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -292,9 +292,5 @@ void intel_crt_init(struct drm_device *dev) drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs); drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs); - /* create dpms property */ - drm_mode_create_dpms_property(dev); - drm_connector_attach_property(connector, dev->mode_config.dpms_property, 0); - drm_sysfs_connector_add(connector); } -- cgit v1.2.3 From e810cb9243fe6c4905182869d9e3272d861a14cb Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Sun, 6 Jul 2008 10:52:25 +0200 Subject: modesetting-101: rename modeflags, as to avoid conflicts with the xorg definitions --- linux-core/intel_crt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index b9e8ee63..4326aef9 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -74,7 +74,7 @@ static void intel_crt_restore(struct drm_connector *connector) static int intel_crt_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { - if (mode->flags & V_DBLSCAN) + if (mode->flags & DRM_MODE_FLAG_DBLSCAN) return MODE_NO_DBLESCAN; if (mode->clock > 400000 || mode->clock < 25000) @@ -118,9 +118,9 @@ static void intel_crt_mode_set(struct drm_encoder *encoder, } adpa = 0; - if (adjusted_mode->flags & V_PHSYNC) + if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) adpa |= ADPA_HSYNC_ACTIVE_HIGH; - if (adjusted_mode->flags & V_PVSYNC) + if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC) adpa |= ADPA_VSYNC_ACTIVE_HIGH; if (intel_crtc->pipe == 0) -- cgit v1.2.3 From 6738e7b00bf05529303ed690873495db6d83337c Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Sun, 6 Jul 2008 11:08:49 +0200 Subject: modesetting-101: Rename DPMS modes to avoid compatibility issues with xorg definitions. --- linux-core/intel_crt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 4326aef9..1b2b5b7e 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -44,16 +44,16 @@ static void intel_crt_dpms(struct drm_encoder *encoder, int mode) temp &= ~ADPA_DAC_ENABLE; switch(mode) { - case DPMSModeOn: + case DRM_MODE_DPMS_ON: temp |= ADPA_DAC_ENABLE; break; - case DPMSModeStandby: + case DRM_MODE_DPMS_STANDBY: temp |= ADPA_DAC_ENABLE | ADPA_HSYNC_CNTL_DISABLE; break; - case DPMSModeSuspend: + case DRM_MODE_DPMS_SUSPEND: temp |= ADPA_DAC_ENABLE | ADPA_VSYNC_CNTL_DISABLE; break; - case DPMSModeOff: + case DRM_MODE_DPMS_OFF: temp |= ADPA_HSYNC_CNTL_DISABLE | ADPA_VSYNC_CNTL_DISABLE; break; } -- cgit v1.2.3 From 7fd8a5de63781f6faa053509c80e02e8f1cdbb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Mon, 7 Jul 2008 11:56:59 -0400 Subject: Use lowercase bool constants. --- linux-core/intel_crt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index b9e8ee63..2e1611e1 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -136,8 +136,8 @@ static void intel_crt_mode_set(struct drm_encoder *encoder, * * Not for i915G/i915GM * - * \return TRUE if CRT is connected. - * \return FALSE if CRT is disconnected. + * \return true if CRT is connected. + * \return false if CRT is disconnected. */ static bool intel_crt_detect_hotplug(struct drm_connector *connector) { -- cgit v1.2.3 From 3ef1d05001a9e28ed52536de7e020323d8d34d83 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Sun, 20 Jul 2008 14:51:22 +0200 Subject: modesetting-101: set_property should return an int, not a bool --- linux-core/intel_crt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux-core/intel_crt.c') diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 1b2b5b7e..8e1b833a 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -210,7 +210,7 @@ static int intel_crt_get_modes(struct drm_connector *connector) return intel_ddc_get_modes(intel_output); } -static bool intel_crt_set_property(struct drm_connector *connector, +static int intel_crt_set_property(struct drm_connector *connector, struct drm_property *property, uint64_t value) { @@ -219,7 +219,7 @@ static bool intel_crt_set_property(struct drm_connector *connector, if (property == dev->mode_config.dpms_property && connector->encoder) intel_crt_dpms(connector->encoder, (uint32_t)(value & 0xf)); - return true; + return 0; } /* -- cgit v1.2.3