28 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
30 #define MRST_BLC_MAX_PWM_REG_FREQ 0xFFFF
31 #define BLC_PWM_PRECISION_FACTOR 100
32 #define BLC_PWM_FREQ_CALC_CONSTANT 32
34 #define BRIGHTNESS_MIN_LEVEL 1
35 #define BRIGHTNESS_MAX_LEVEL 100
36 #define BRIGHTNESS_MASK 0xFF
37 #define BLC_POLARITY_NORMAL 0
38 #define BLC_POLARITY_INVERSE 1
39 #define BLC_ADJUSTMENT_MAX 100
41 #define MDFLD_BLC_PWM_PRECISION_FACTOR 10
42 #define MDFLD_BLC_MAX_PWM_REG_FREQ 0xFFFE
43 #define MDFLD_BLC_MIN_PWM_REG_FREQ 0x2
45 #define MDFLD_BACKLIGHT_PWM_POLARITY_BIT_CLEAR (0xFFFE)
46 #define MDFLD_BACKLIGHT_PWM_CTL_SHIFT (16)
53 (
struct drm_device *)bl_get_data(mdfld_backlight_device);
57 DRM_DEBUG_DRIVER(
"backlight level set to %d\n", level);
60 if (level < BRIGHTNESS_MIN_LEVEL)
61 level = BRIGHTNESS_MIN_LEVEL;
64 u32 adjusted_level = 0;
70 adjusted_level = level * dev_priv->
blc_adj2;
71 adjusted_level = adjusted_level / BLC_ADJUSTMENT_MAX;
99 (
struct drm_device *)bl_get_data(mdfld_backlight_device);
102 DRM_DEBUG_DRIVER(
"brightness = 0x%x \n", dev_priv->
brightness);
113 static int device_backlight_init(
struct drm_device *dev)
118 dev_priv->
blc_adj1 = BLC_ADJUSTMENT_MAX;
119 dev_priv->
blc_adj2 = BLC_ADJUSTMENT_MAX;
124 static int mdfld_backlight_init(
struct drm_device *dev)
133 NULL, (
void *)dev, &mdfld_ops, &props);
135 if (IS_ERR(mdfld_backlight_device))
136 return PTR_ERR(mdfld_backlight_device);
138 ret = device_backlight_init(dev);
144 backlight_update_status(mdfld_backlight_device);
151 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
152 return mdfld_backlight_device;
166 static int mdfld_save_display_registers(
struct drm_device *dev,
int pipenum)
192 DRM_ERROR(
"%s, invalid pipe number.\n", __func__);
217 for (i = 0; i < 256; i++)
240 static int mdfld_restore_display_registers(
struct drm_device *dev,
int pipenum)
275 DRM_ERROR(
"%s, invalid pipe number.\n", __func__);
296 dpll &= ~MDFLD_PWR_GATE_EN;
312 while (timeout < 20000 &&
318 if (timeout == 20000) {
319 DRM_ERROR(
"%s, can't lock DSIPLL.\n",
346 for (i = 0; i < 256; i++)
408 for (i = 0; i < 256; i++)
414 static int mdfld_save_registers(
struct drm_device *dev)
417 mdfld_save_display_registers(dev, 0);
418 mdfld_save_display_registers(dev, 2);
425 static int mdfld_restore_registers(
struct drm_device *dev)
427 mdfld_restore_display_registers(dev, 2);
428 mdfld_restore_display_registers(dev, 0);
434 static int mdfld_power_down(
struct drm_device *dev)
440 static int mdfld_power_up(
struct drm_device *dev)
447 static const struct psb_offset mdfld_regmap[3] = {
518 static int mdfld_chip_setup(
struct drm_device *dev)
521 if (pci_enable_msi(dev->pdev))
522 dev_warn(dev->dev,
"Enabling MSI failed!\n");
523 dev_priv->
regmap = mdfld_regmap;
532 .lvds_mask = (1 << 1),
534 .cursor_needs_phys = 0,
537 .chip_setup = mdfld_chip_setup,
543 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
544 .backlight_init = mdfld_backlight_init,
547 .save_regs = mdfld_save_registers,
548 .restore_regs = mdfld_restore_registers,
549 .power_down = mdfld_power_down,
550 .power_up = mdfld_power_up,