21 #include <linux/module.h>
40 dev_err(dev->dev,
"DSI is not supported\n");
50 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
52 #define MRST_BLC_MAX_PWM_REG_FREQ 0xFFFF
53 #define BLC_PWM_PRECISION_FACTOR 100
54 #define BLC_PWM_FREQ_CALC_CONSTANT 32
56 #define BLC_ADJUSTMENT_MAX 100
59 static int oaktrail_brightness;
63 struct drm_device *dev = bl_get_data(oaktrail_backlight_device);
76 blc_pwm_ctl = level * max_pwm_blc / 100;
81 blc_pwm_ctl = blc_pwm_ctl * dev_priv->
blc_adj1;
82 blc_pwm_ctl = blc_pwm_ctl / 100;
87 blc_pwm_ctl = blc_pwm_ctl * dev_priv->
blc_adj2;
88 blc_pwm_ctl = blc_pwm_ctl / 100;
95 oaktrail_brightness =
level;
104 return oaktrail_brightness;
107 static int device_backlight_init(
struct drm_device *dev)
110 unsigned long core_clock;
115 dev_priv->
blc_adj1 = BLC_ADJUSTMENT_MAX;
116 dev_priv->
blc_adj2 = BLC_ADJUSTMENT_MAX;
119 blc_pwm_precision_factor = BLC_PWM_PRECISION_FACTOR;
123 value = (core_clock *
MHz) / BLC_PWM_FREQ_CALC_CONSTANT;
124 value *= blc_pwm_precision_factor;
125 value /= bl_max_freq;
126 value /= blc_pwm_precision_factor;
141 .update_status = oaktrail_set_brightness,
144 static int oaktrail_backlight_init(
struct drm_device *dev)
151 props.max_brightness = 100;
155 NULL, (
void *)dev, &oaktrail_ops, &props);
157 if (IS_ERR(oaktrail_backlight_device))
158 return PTR_ERR(oaktrail_backlight_device);
160 ret = device_backlight_init(dev);
165 oaktrail_backlight_device->
props.brightness = 100;
166 oaktrail_backlight_device->
props.max_brightness = 100;
167 backlight_update_status(oaktrail_backlight_device);
186 static int oaktrail_save_display_registers(
struct drm_device *dev)
230 for (i = 0; i < 256; i++)
261 regs->
psb.saveHISTOGRAM_INT_CONTROL_REG =
263 regs->
psb.saveHISTOGRAM_LOGIC_CONTROL_REG =
273 }
while (pp_stat & 0x80000000);
300 static int oaktrail_restore_display_registers(
struct drm_device *dev)
361 for (i = 0; i < 256; i++)
383 }
while (pp_stat & 0x08000000);
388 }
while (pp_stat & 0x10000000);
415 static int oaktrail_power_down(
struct drm_device *dev)
426 if ((pwr_sts & pwr_mask) == pwr_mask)
439 static int oaktrail_power_up(
struct drm_device *dev)
443 u32 pwr_sts, pwr_cnt;
446 pwr_cnt &= ~pwr_mask;
451 if ((pwr_sts & pwr_mask) == 0)
460 static const struct psb_offset oaktrail_regmap[2] = {
511 static int oaktrail_chip_setup(
struct drm_device *dev)
516 if (pci_enable_msi(dev->pdev))
517 dev_warn(dev->dev,
"Enabling MSI failed!\n");
519 dev_priv->
regmap = oaktrail_regmap;
533 static void oaktrail_teardown(
struct drm_device *dev)
547 .hdmi_mask = (1 << 0),
549 .cursor_needs_phys = 0,
552 .chip_setup = oaktrail_chip_setup,
553 .chip_teardown = oaktrail_teardown,
557 .output_init = oaktrail_output_init,
559 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
560 .backlight_init = oaktrail_backlight_init,
563 .save_regs = oaktrail_save_display_registers,
564 .restore_regs = oaktrail_restore_display_registers,
565 .power_down = oaktrail_power_down,
566 .power_up = oaktrail_power_up,