diff -Napur -X /home/jbarnes/dontdiff linux-2.6.21-rc4/drivers/char/drm/i915_dma.c linux-2.6.21-rc4-modeset/drivers/char/drm/i915_dma.c --- linux-2.6.21-rc4/drivers/char/drm/i915_dma.c 2007-03-15 17:20:01.000000000 -0700 +++ linux-2.6.21-rc4-modeset/drivers/char/drm/i915_dma.c 2007-03-16 14:03:34.000000000 -0700 @@ -36,6 +36,43 @@ dev->pci_device == 0x2992 || \ dev->pci_device == 0x29A2) +/** + * Sets the backlight level. + * + * \param level backlight level, from 0 to i830_lvds_get_max_backlight(). + */ +static void lvds_set_backlight(drm_device_t *dev, unsigned long level) +{ + drm_i915_private_t *dev_priv = dev->dev_private; + unsigned long blc_pwm_ctl; + + blc_pwm_ctl = I915_READ(BLC_PWM_CTL) & ~BACKLIGHT_DUTY_CYCLE_MASK; + I915_WRITE(BLC_PWM_CTL, blc_pwm_ctl | + (level << BACKLIGHT_DUTY_CYCLE_SHIFT)); +} + +/** + * Returns the maximum level of the backlight duty cycle field. + */ +static unsigned long lvds_get_max_backlight(drm_device_t *dev) +{ + drm_i915_private_t *dev_priv = dev->dev_private; + + return ((I915_READ(BLC_PWM_CTL) & BACKLIGHT_MODULATION_FREQ_MASK) >> + BACKLIGHT_MODULATION_FREQ_SHIFT) * 2; +} + +static int i915_backlight(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + + lvds_set_backlight(dev, 2); + printk(KERN_ERR "max backlight value: %d\n", + lvds_get_max_backlight(dev)); + return 0; +} + + /* Really want an OS-independent resettable timer. Would like to have * this loop run for (eg) 3 sec, but have the timer reset every time * the head pointer changes, so that EBUSY only happens if the ring @@ -784,6 +821,7 @@ drm_ioctl_desc_t i915_ioctls[] = { [DRM_IOCTL_NR(DRM_I915_SET_VBLANK_PIPE)] = { i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, [DRM_IOCTL_NR(DRM_I915_GET_VBLANK_PIPE)] = { i915_vblank_pipe_get, DRM_AUTH }, [DRM_IOCTL_NR(DRM_I915_VBLANK_SWAP)] = {i915_vblank_swap, DRM_AUTH}, + [DRM_IOCTL_NR(DRM_I915_BACKLIGHT)] = {i915_backlight, DRM_AUTH}, }; int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); diff -Napur -X /home/jbarnes/dontdiff linux-2.6.21-rc4/drivers/char/drm/i915_drm.h linux-2.6.21-rc4-modeset/drivers/char/drm/i915_drm.h --- linux-2.6.21-rc4/drivers/char/drm/i915_drm.h 2007-03-15 17:20:01.000000000 -0700 +++ linux-2.6.21-rc4-modeset/drivers/char/drm/i915_drm.h 2007-03-16 13:38:16.000000000 -0700 @@ -142,6 +142,7 @@ typedef struct _drm_i915_sarea { #define DRM_I915_SET_VBLANK_PIPE 0x0d #define DRM_I915_GET_VBLANK_PIPE 0x0e #define DRM_I915_VBLANK_SWAP 0x0f +#define DRM_I915_BACKLIGHT 0x40 #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) @@ -159,6 +160,7 @@ typedef struct _drm_i915_sarea { #define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t) #define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t) #define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t) +#define DRM_IOCTL_I915_BACKLIGHT DRM_IO(DRM_COMMAND_BASE + DRM_I915_BACKLIGHT) /* Allow drivers to submit batchbuffers directly to hardware, relying * on the security mechanisms provided by hardware. diff -Napur -X /home/jbarnes/dontdiff linux-2.6.21-rc4/drivers/char/drm/i915_drv.h linux-2.6.21-rc4-modeset/drivers/char/drm/i915_drv.h --- linux-2.6.21-rc4/drivers/char/drm/i915_drv.h 2007-03-15 17:20:01.000000000 -0700 +++ linux-2.6.21-rc4-modeset/drivers/char/drm/i915_drv.h 2007-03-16 12:36:29.000000000 -0700 @@ -294,4 +294,24 @@ extern int i915_wait_ring(drm_device_t * #define READ_BREADCRUMB(dev_priv) (((u32 *)(dev_priv->hw_status_page))[5]) +#define BLC_PWM_CTL 0x61254 +#define BACKLIGHT_MODULATION_FREQ_SHIFT (17) +/** + * This is the most significant 15 bits of the number of backlight cycles in a + * complete cycle of the modulated backlight control. + * + * The actual value is this field multiplied by two. + */ +#define BACKLIGHT_MODULATION_FREQ_MASK (0x7fff << 17) +#define BLM_LEGACY_MODE (1 << 16) +/** + * This is the number of cycles out of the backlight modulation cycle for which + * the backlight is on. + * + * This field must be no greater than the number of cycles in the complete + * backlight modulation cycle. + */ +#define BACKLIGHT_DUTY_CYCLE_SHIFT (0) +#define BACKLIGHT_DUTY_CYCLE_MASK (0xffff) + #endif