Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
# other random bits
nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
nouveau-$(CONFIG_ACPI) += nouveau_acpi.o
# other random bits
nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
nouveau-$(CONFIG_ACPI) += nouveau_acpi.o
+nouveau-$(CONFIG_DRM_NOUVEAU_BACKLIGHT) += nouveau_backlight.o
##
## unported bits below
##
## unported bits below
nouveau-y += nv04_pm.o nv40_pm.o nv50_pm.o nva3_pm.o nvc0_pm.o
nouveau-y += nouveau_mem.o
nouveau-y += nv04_pm.o nv40_pm.o nv50_pm.o nva3_pm.o nvc0_pm.o
nouveau-y += nouveau_mem.o
-# optional stuff
-nouveau-$(CONFIG_DRM_NOUVEAU_BACKLIGHT) += nouveau_backlight.o
-
-
obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o
obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o
#include <linux/backlight.h>
#include <linux/acpi.h>
#include <linux/backlight.h>
#include <linux/acpi.h>
-#include "drmP.h"
-#include "nouveau_drv.h"
-#include <nouveau_drm.h>
+#include "nouveau_drm.h"
#include "nouveau_reg.h"
#include "nouveau_encoder.h"
static int
nv40_get_intensity(struct backlight_device *bd)
{
#include "nouveau_reg.h"
#include "nouveau_encoder.h"
static int
nv40_get_intensity(struct backlight_device *bd)
{
- struct drm_device *dev = bl_get_data(bd);
- int val = (nv_rd32(dev, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK)
- >> 16;
+ struct nouveau_drm *drm = bl_get_data(bd);
+ struct nouveau_device *device = nv_device(drm->device);
+ int val = (nv_rd32(device, NV40_PMC_BACKLIGHT) &
+ NV40_PMC_BACKLIGHT_MASK) >> 16;
static int
nv40_set_intensity(struct backlight_device *bd)
{
static int
nv40_set_intensity(struct backlight_device *bd)
{
- struct drm_device *dev = bl_get_data(bd);
+ struct nouveau_drm *drm = bl_get_data(bd);
+ struct nouveau_device *device = nv_device(drm->device);
int val = bd->props.brightness;
int val = bd->props.brightness;
- int reg = nv_rd32(dev, NV40_PMC_BACKLIGHT);
+ int reg = nv_rd32(device, NV40_PMC_BACKLIGHT);
- nv_wr32(dev, NV40_PMC_BACKLIGHT,
+ nv_wr32(device, NV40_PMC_BACKLIGHT,
(val << 16) | (reg & ~NV40_PMC_BACKLIGHT_MASK));
return 0;
(val << 16) | (reg & ~NV40_PMC_BACKLIGHT_MASK));
return 0;
static int
nv40_backlight_init(struct drm_connector *connector)
{
static int
nv40_backlight_init(struct drm_connector *connector)
{
- struct drm_device *dev = connector->dev;
- struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct nouveau_drm *drm = nouveau_newpriv(connector->dev);
+ struct nouveau_device *device = nv_device(drm->device);
struct backlight_properties props;
struct backlight_device *bd;
struct backlight_properties props;
struct backlight_device *bd;
- if (!(nv_rd32(dev, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK))
+ if (!(nv_rd32(device, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK))
return 0;
memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = 31;
return 0;
memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_RAW;
props.max_brightness = 31;
- bd = backlight_device_register("nv_backlight", &connector->kdev, dev,
+ bd = backlight_device_register("nv_backlight", &connector->kdev, drm,
- if (IS_ERR(bd))
- return PTR_ERR(bd);
-
- dev_priv->backlight = bd;
bd->props.brightness = nv40_get_intensity(bd);
backlight_update_status(bd);
bd->props.brightness = nv40_get_intensity(bd);
backlight_update_status(bd);
nv50_get_intensity(struct backlight_device *bd)
{
struct nouveau_encoder *nv_encoder = bl_get_data(bd);
nv50_get_intensity(struct backlight_device *bd)
{
struct nouveau_encoder *nv_encoder = bl_get_data(bd);
- struct drm_device *dev = nv_encoder->base.base.dev;
+ struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev);
+ struct nouveau_device *device = nv_device(drm->device);
int or = nv_encoder->or;
u32 div = 1025;
u32 val;
int or = nv_encoder->or;
u32 div = 1025;
u32 val;
- val = nv_rd32(dev, NV50_PDISP_SOR_PWM_CTL(or));
+ val = nv_rd32(device, NV50_PDISP_SOR_PWM_CTL(or));
val &= NV50_PDISP_SOR_PWM_CTL_VAL;
return ((val * 100) + (div / 2)) / div;
}
val &= NV50_PDISP_SOR_PWM_CTL_VAL;
return ((val * 100) + (div / 2)) / div;
}
nv50_set_intensity(struct backlight_device *bd)
{
struct nouveau_encoder *nv_encoder = bl_get_data(bd);
nv50_set_intensity(struct backlight_device *bd)
{
struct nouveau_encoder *nv_encoder = bl_get_data(bd);
- struct drm_device *dev = nv_encoder->base.base.dev;
+ struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev);
+ struct nouveau_device *device = nv_device(drm->device);
int or = nv_encoder->or;
u32 div = 1025;
u32 val = (bd->props.brightness * div) / 100;
int or = nv_encoder->or;
u32 div = 1025;
u32 val = (bd->props.brightness * div) / 100;
- nv_wr32(dev, NV50_PDISP_SOR_PWM_CTL(or),
- NV50_PDISP_SOR_PWM_CTL_NEW | val);
+ nv_wr32(device, NV50_PDISP_SOR_PWM_CTL(or),
+ NV50_PDISP_SOR_PWM_CTL_NEW | val);
nva3_get_intensity(struct backlight_device *bd)
{
struct nouveau_encoder *nv_encoder = bl_get_data(bd);
nva3_get_intensity(struct backlight_device *bd)
{
struct nouveau_encoder *nv_encoder = bl_get_data(bd);
- struct drm_device *dev = nv_encoder->base.base.dev;
+ struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev);
+ struct nouveau_device *device = nv_device(drm->device);
int or = nv_encoder->or;
u32 div, val;
int or = nv_encoder->or;
u32 div, val;
- div = nv_rd32(dev, NV50_PDISP_SOR_PWM_DIV(or));
- val = nv_rd32(dev, NV50_PDISP_SOR_PWM_CTL(or));
+ div = nv_rd32(device, NV50_PDISP_SOR_PWM_DIV(or));
+ val = nv_rd32(device, NV50_PDISP_SOR_PWM_CTL(or));
val &= NVA3_PDISP_SOR_PWM_CTL_VAL;
if (div && div >= val)
return ((val * 100) + (div / 2)) / div;
val &= NVA3_PDISP_SOR_PWM_CTL_VAL;
if (div && div >= val)
return ((val * 100) + (div / 2)) / div;
nva3_set_intensity(struct backlight_device *bd)
{
struct nouveau_encoder *nv_encoder = bl_get_data(bd);
nva3_set_intensity(struct backlight_device *bd)
{
struct nouveau_encoder *nv_encoder = bl_get_data(bd);
- struct drm_device *dev = nv_encoder->base.base.dev;
+ struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev);
+ struct nouveau_device *device = nv_device(drm->device);
int or = nv_encoder->or;
u32 div, val;
int or = nv_encoder->or;
u32 div, val;
- div = nv_rd32(dev, NV50_PDISP_SOR_PWM_DIV(or));
+ div = nv_rd32(device, NV50_PDISP_SOR_PWM_DIV(or));
val = (bd->props.brightness * div) / 100;
if (div) {
val = (bd->props.brightness * div) / 100;
if (div) {
- nv_wr32(dev, NV50_PDISP_SOR_PWM_CTL(or), val |
- NV50_PDISP_SOR_PWM_CTL_NEW |
- NVA3_PDISP_SOR_PWM_CTL_UNK);
+ nv_wr32(device, NV50_PDISP_SOR_PWM_CTL(or), val |
+ NV50_PDISP_SOR_PWM_CTL_NEW |
+ NVA3_PDISP_SOR_PWM_CTL_UNK);
static int
nv50_backlight_init(struct drm_connector *connector)
{
static int
nv50_backlight_init(struct drm_connector *connector)
{
- struct drm_device *dev = connector->dev;
- struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct nouveau_drm *drm = nouveau_newpriv(connector->dev);
+ struct nouveau_device *device = nv_device(drm->device);
struct nouveau_encoder *nv_encoder;
struct backlight_properties props;
struct backlight_device *bd;
struct nouveau_encoder *nv_encoder;
struct backlight_properties props;
struct backlight_device *bd;
- if (!nv_rd32(dev, NV50_PDISP_SOR_PWM_CTL(nv_encoder->or)))
+ if (!nv_rd32(device, NV50_PDISP_SOR_PWM_CTL(nv_encoder->or)))
- if (dev_priv->chipset <= 0xa0 ||
- dev_priv->chipset == 0xaa ||
- dev_priv->chipset == 0xac)
+ if (device->chipset <= 0xa0 ||
+ device->chipset == 0xaa ||
+ device->chipset == 0xac)
ops = &nv50_bl_ops;
else
ops = &nva3_bl_ops;
ops = &nv50_bl_ops;
else
ops = &nva3_bl_ops;
if (IS_ERR(bd))
return PTR_ERR(bd);
if (IS_ERR(bd))
return PTR_ERR(bd);
- dev_priv->backlight = bd;
bd->props.brightness = bd->ops->get_brightness(bd);
backlight_update_status(bd);
return 0;
bd->props.brightness = bd->ops->get_brightness(bd);
backlight_update_status(bd);
return 0;
int
nouveau_backlight_init(struct drm_device *dev)
{
int
nouveau_backlight_init(struct drm_device *dev)
{
- struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct nouveau_drm *drm = nouveau_newpriv(dev);
+ struct nouveau_device *device = nv_device(drm->device);
struct drm_connector *connector;
#ifdef CONFIG_ACPI
if (acpi_video_backlight_support()) {
struct drm_connector *connector;
#ifdef CONFIG_ACPI
if (acpi_video_backlight_support()) {
- NV_INFO(dev, "ACPI backlight interface available, "
+ NV_INFO(drm, "ACPI backlight interface available, "
"not registering our own\n");
return 0;
}
"not registering our own\n");
return 0;
}
connector->connector_type != DRM_MODE_CONNECTOR_eDP)
continue;
connector->connector_type != DRM_MODE_CONNECTOR_eDP)
continue;
- switch (dev_priv->card_type) {
+ switch (device->card_type) {
case NV_40:
return nv40_backlight_init(connector);
case NV_50:
case NV_40:
return nv40_backlight_init(connector);
case NV_50:
void
nouveau_backlight_exit(struct drm_device *dev)
{
void
nouveau_backlight_exit(struct drm_device *dev)
{
- struct drm_nouveau_private *dev_priv = dev->dev_private;
+ struct nouveau_drm *drm = nouveau_newpriv(dev);
- if (dev_priv->backlight) {
- backlight_device_unregister(dev_priv->backlight);
- dev_priv->backlight = NULL;
+ if (drm->backlight) {
+ backlight_device_unregister(drm->backlight);
+ drm->backlight = NULL;
struct nouveau_drm_tile reg[15];
spinlock_t lock;
} tile;
struct nouveau_drm_tile reg[15];
spinlock_t lock;
} tile;
+
+ struct backlight_device *backlight;
};
static inline struct nouveau_drm *
};
static inline struct nouveau_drm *
spinlock_t context_switch_lock;
struct nvbios vbios;
spinlock_t context_switch_lock;
struct nvbios vbios;
- u8 *mxms;
-
- struct backlight_device *backlight;
};
static inline struct drm_nouveau_private *
};
static inline struct drm_nouveau_private *
dev->pdev->subsystem_device == sub_device;
}
dev->pdev->subsystem_device == sub_device;
}
+static inline struct nv04_display *
+nv04_display(struct drm_device *dev)
+{
+ struct drm_nouveau_private *dev_priv = dev->dev_private;
+ return dev_priv->engine.display.priv;
+}
+
#endif /* __NOUVEAU_DRV_H__ */
#endif /* __NOUVEAU_DRV_H__ */
#ifndef __NOUVEAU_ENCODER_H__
#define __NOUVEAU_ENCODER_H__
#ifndef __NOUVEAU_ENCODER_H__
#define __NOUVEAU_ENCODER_H__
+#include <subdev/bios/dcb.h>
+
#include "drm_encoder_slave.h"
#include "drm_encoder_slave.h"
-#include "nouveau_drv.h"
#include "nv04_display.h"
#define NV_DPMS_CLEARED 0x80
#include "nv04_display.h"
#define NV_DPMS_CLEARED 0x80
#ifndef __NV04_DISPLAY_H__
#define __NV04_DISPLAY_H__
#ifndef __NV04_DISPLAY_H__
#define __NV04_DISPLAY_H__
+#include <subdev/bios/pll.h>
+
enum nv04_fp_display_regs {
FP_DISPLAY_END,
FP_TOTAL,
enum nv04_fp_display_regs {
FP_DISPLAY_END,
FP_TOTAL,
uint32_t dac_users[4];
};
uint32_t dac_users[4];
};
-static inline struct nv04_display *
-nv04_display(struct drm_device *dev)
-{
- struct drm_nouveau_private *dev_priv = dev->dev_private;
- return dev_priv->engine.display.priv;
-}
-
/* nv04_display.c */
int nv04_display_early_init(struct drm_device *);
void nv04_display_late_takedown(struct drm_device *);
/* nv04_display.c */
int nv04_display_early_init(struct drm_device *);
void nv04_display_late_takedown(struct drm_device *);