--- nouveau_backlight.c.orig 2016-08-04 20:59:42.590183002 -0400 +++ nouveau_backlight.c 2016-08-04 21:08:25.291126244 -0400 @@ -36,6 +36,74 @@ #include "nouveau_reg.h" #include "nouveau_encoder.h" + +#ifdef __powerpc__ + +const int NV30_BL_CURVE[9] = {0x000,0x16d,0x1f7,0x281,0x30b,0x395,0x41f,0x4a9,0x534}; + +static int +nv30_get_intensity(struct backlight_device *bd) +{ + struct nouveau_drm *drm = bl_get_data(bd); + struct nvif_object *device = &drm->device.object; + int val = (nvif_rd32(device, NV30_PMC_BACKLIGHT) & + NV30_PMC_BACKLIGHT_MASK) >> 16; + int i; + for(i=0;idevice.object; + int val = bd->props.brightness; + + nvif_wr32(device, NV30_PMC_BACKLIGHT, + (NV30_BL_CURVE[val] << 16) + 0x80000535); + + return 0; +} + +static const struct backlight_ops nv30_bl_ops = { + .options = BL_CORE_SUSPENDRESUME, + .get_brightness = nv30_get_intensity, + .update_status = nv30_set_intensity, +}; + +static int +nv30_backlight_init(struct drm_connector *connector) +{ + struct nouveau_drm *drm = nouveau_drm(connector->dev); + struct nvif_object *device = &drm->device.object; + struct backlight_properties props; + struct backlight_device *bd; + + if (!(nvif_rd32(device, NV30_PMC_BACKLIGHT) & NV30_PMC_BACKLIGHT_MASK)) + return 0; + + memset(&props, 0, sizeof(struct backlight_properties)); + props.type = BACKLIGHT_RAW; + props.max_brightness = sizeof(NV30_BL_CURVE)/sizeof(NV30_BL_CURVE[0])-1; + bd = backlight_device_register("nv_backlight", connector->kdev, drm, + &nv30_bl_ops, &props); + if (IS_ERR(bd)) + return PTR_ERR(bd); + drm->backlight = bd; + bd->props.brightness = nv30_get_intensity(bd); + backlight_update_status(bd); + + return 0; +} + +#endif + static int nv40_get_intensity(struct backlight_device *bd) { @@ -227,6 +295,10 @@ continue; switch (device->info.family) { +#ifdef __powerpc__ + case NV_DEVICE_INFO_V0_RANKINE: + return nv30_backlight_init(connector); +#endif case NV_DEVICE_INFO_V0_CURIE: return nv40_backlight_init(connector); case NV_DEVICE_INFO_V0_TESLA: