38 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
44 #define BLC_PWM_PRECISION_FACTOR 100
45 #define BLC_PWM_FREQ_CALC_CONSTANT 32
48 #define PSB_BLC_PWM_PRECISION_FACTOR 10
49 #define PSB_BLC_MAX_PWM_REG_FREQ 0xFFFE
50 #define PSB_BLC_MIN_PWM_REG_FREQ 0x2
52 #define PSB_BACKLIGHT_PWM_POLARITY_BIT_CLEAR (0xFFFE)
53 #define PSB_BACKLIGHT_PWM_CTL_SHIFT (16)
55 static int psb_brightness;
63 return psb_brightness;
70 unsigned long core_clock;
79 dev_err(dev->dev,
"Has no valid LVDS backlight info\n");
82 bl_max_freq = dev_priv->
lvds_bl->freq;
87 value = (core_clock *
MHz) / BLC_PWM_FREQ_CALC_CONSTANT;
88 value *= blc_pwm_precision_factor;
90 value /= blc_pwm_precision_factor;
105 struct drm_device *dev = bl_get_data(psb_backlight_device);
113 psb_brightness =
level;
118 .get_brightness = psb_get_brightness,
119 .update_status = psb_set_brightness,
122 static int psb_backlight_init(
struct drm_device *dev)
129 props.max_brightness = 100;
133 NULL, (
void *)dev, &psb_ops, &props);
134 if (IS_ERR(psb_backlight_device))
135 return PTR_ERR(psb_backlight_device);
137 ret = psb_backlight_setup(dev);
140 psb_backlight_device =
NULL;
143 psb_backlight_device->
props.brightness = 100;
144 psb_backlight_device->
props.max_brightness = 100;
145 backlight_update_status(psb_backlight_device);
161 static void psb_init_pm(
struct drm_device *dev)
179 static int psb_save_display_registers(
struct drm_device *dev)
200 crtc->
funcs->save(crtc);
204 if (connector->funcs->save)
205 connector->funcs->save(connector);
240 crtc->funcs->restore(crtc);
243 if (connector->funcs->restore)
244 connector->funcs->restore(connector);
255 static int psb_power_up(
struct drm_device *dev)
260 static void psb_get_core_freq(
struct drm_device *dev)
269 pci_write_config_dword(pci_root, 0xD0, 0xD0050300);
270 pci_read_config_dword(pci_root, 0xD4, &clock);
273 switch (clock & 0x07) {
300 static const struct psb_offset psb_regmap[2] = {
351 static int psb_chip_setup(
struct drm_device *dev)
354 dev_priv->
regmap = psb_regmap;
355 psb_get_core_freq(dev);
362 static void psb_chip_teardown(
struct drm_device *dev)
374 .hdmi_mask = (1 << 0),
376 .cursor_needs_phys = 1,
378 .chip_setup = psb_chip_setup,
379 .chip_teardown = psb_chip_teardown,
384 .output_init = psb_output_init,
386 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
387 .backlight_init = psb_backlight_init,
390 .init_pm = psb_init_pm,
391 .save_regs = psb_save_display_registers,
392 .restore_regs = psb_restore_display_registers,
393 .power_down = psb_power_down,
394 .power_up = psb_power_up,