-/* $OpenBSD: drmP.h,v 1.212 2017/07/01 16:00:25 kettenis Exp $ */
+/* $OpenBSD: drmP.h,v 1.213 2017/07/05 20:30:13 kettenis Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
#include <dev/pci/agpvar.h>
#include <machine/bus.h>
-#define CONFIG_DRM_FBDEV_EMULATION
+#define CONFIG_DRM_FBDEV_EMULATION 1
+#define CONFIG_BACKLIGHT_CLASS_DEVICE 1
#include "drm_linux.h"
#include "drm_linux_list.h"
-/* $OpenBSD: drm_linux.c,v 1.13 2017/07/01 16:14:10 kettenis Exp $ */
+/* $OpenBSD: drm_linux.c,v 1.14 2017/07/05 20:30:13 kettenis Exp $ */
/*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
}
#endif
+
+struct backlight_device *
+backlight_device_register(const char *name, void *kdev, void *data,
+ const struct backlight_ops *ops, struct backlight_properties *props)
+{
+ struct backlight_device *bd;
+
+ bd = malloc(sizeof(*bd), M_DRM, M_WAITOK);
+ bd->ops = ops;
+ bd->props = *props;
+ bd->data = data;
+
+ return bd;
+}
+
+void
+backlight_device_unregister(struct backlight_device *bd)
+{
+ free(bd, M_DRM, sizeof(*bd));
+}
-/* $OpenBSD: drm_linux.h,v 1.52 2017/07/02 20:58:55 kettenis Exp $ */
+/* $OpenBSD: drm_linux.h,v 1.53 2017/07/05 20:30:13 kettenis Exp $ */
/*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis
*
#define acpi_video_register()
#define acpi_video_unregister()
+struct backlight_device;
+
+struct backlight_properties {
+ int type;
+ int max_brightness;
+ int brightness;
+ int power;
+};
+
+struct backlight_ops {
+ int (*update_status)(struct backlight_device *);
+ int (*get_brightness)(struct backlight_device *);
+};
+
+struct backlight_device {
+ const struct backlight_ops *ops;
+ struct backlight_properties props;
+ void *data;
+};
+
+#define bl_get_data(bd) (bd)->data
+
+#define BACKLIGHT_RAW 0
+
+struct backlight_device *backlight_device_register(const char *, void *,
+ void *, const struct backlight_ops *, struct backlight_properties *);
+void backlight_device_unregister(struct backlight_device *);
+
+static inline void
+backlight_update_status(struct backlight_device *bd)
+{
+ bd->ops->update_status(bd);
+};
+
#define MIPI_DSI_V_SYNC_START 0x01
#define MIPI_DSI_V_SYNC_END 0x11
#define MIPI_DSI_H_SYNC_START 0x21
inteldrm_wsioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
{
struct inteldrm_softc *dev_priv = v;
- struct drm_device *dev = dev_priv->dev;
+ struct backlight_device *bd = dev_priv->backlight;
struct rasops_info *ri = &dev_priv->ro;
struct wsdisplay_fbinfo *wdf;
struct wsdisplay_param *dp = (struct wsdisplay_param *)data;
if (ws_get_param && ws_get_param(dp) == 0)
return 0;
- if (dev_priv->backlight.connector == NULL)
+ if (bd == NULL)
return -1;
switch (dp->param) {
case WSDISPLAYIO_PARAM_BRIGHTNESS:
dp->min = 0;
- dp->max = dev_priv->backlight.props.max_brightness;
- dp->curval = dev_priv->backlight.props.brightness;
+ dp->max = bd->props.max_brightness;
+ dp->curval = bd->ops->get_brightness(bd);
return (dp->max > dp->min) ? 0 : -1;
}
break;
if (ws_set_param && ws_set_param(dp) == 0)
return 0;
- if (dev_priv->backlight.connector == NULL ||
- dp->curval > dev_priv->backlight.props.max_brightness)
+ if (bd == NULL || dp->curval > bd->props.max_brightness)
return -1;
switch (dp->param) {
case WSDISPLAYIO_PARAM_BRIGHTNESS:
- mutex_lock(&dev->mode_config.mutex);
- intel_panel_set_backlight_acpi(dev_priv->backlight.connector,
- dp->curval, dev_priv->backlight.props.max_brightness);
- mutex_unlock(&dev->mode_config.mutex);
+ bd->props.brightness = dp->curval;
+ backlight_update_status(bd);
return 0;
}
break;
struct pci_attach_args *pa = aux;
const struct drm_pcidev *id;
struct intel_device_info *info, *device_info;
+ struct intel_connector *intel_connector;
struct rasops_info *ri = &dev_priv->ro;
struct wsemuldisplaydev_attach_args aa;
extern int vga_console_attached;
intel_fbdev_restore_mode(dev);
+ /* Grab backlight from the first connector that has one. */
+ drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+ list_for_each_entry(intel_connector, &dev->mode_config.connector_list,
+ base.head) {
+ struct intel_panel *panel = &intel_connector->panel;
+
+ if (panel->backlight.present) {
+ dev_priv->backlight = panel->backlight.device;
+ break;
+ }
+ }
+ drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
ri->ri_flg = RI_CENTER | RI_WRONLY | RI_VCONS | RI_CLEAR;
ri->ri_hw = dev_priv;
rasops_init(ri, 160, 160);
-/* $OpenBSD: i915_drv.h,v 1.75 2017/07/01 16:14:10 kettenis Exp $ */
+/* $OpenBSD: i915_drv.h,v 1.76 2017/07/05 20:30:13 kettenis Exp $ */
/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
*/
/*
struct task burner_task;
int burner_fblank;
- struct backlight_device {
- struct intel_connector *connector;
- struct {
- uint32_t brightness;
- uint32_t max_brightness;
- uint32_t power;
- } props;
- } backlight;
+ struct backlight_device *backlight;
struct intel_uncore uncore;
return DIV_ROUND_UP(duty_ns * 100, CRC_PMIC_PWM_PERIOD_NS);
}
-#ifdef __linux__
static u32 intel_panel_get_backlight(struct intel_connector *connector)
{
struct drm_device *dev = connector->base.dev;
DRM_DEBUG_DRIVER("get backlight PWM = %d\n", val);
return val;
}
-#endif
static void lpt_set_backlight(struct intel_connector *connector, u32 level)
{
panel->backlight.set(connector, level);
}
-#ifdef __linux__
-
/* set backlight brightness to level in range [0..max], scaling wrt hw min */
static void intel_panel_set_backlight(struct intel_connector *connector,
u32 user_level, u32 user_max)
mutex_unlock(&dev_priv->backlight_lock);
}
-#endif
-
/* set backlight brightness to level in range [0..max], assuming hw min is
* respected.
*/
-/* $OpenBSD: atombios_encoders.c,v 1.9 2015/04/18 14:47:34 jsg Exp $ */
+/* $OpenBSD: atombios_encoders.c,v 1.10 2017/07/05 20:30:13 kettenis Exp $ */
/*
* Copyright 2007-11 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
memset(&props, 0, sizeof(props));
props.max_brightness = RADEON_MAX_BL_LEVEL;
props.type = BACKLIGHT_RAW;
+#ifdef __linux__
snprintf(bl_name, sizeof(bl_name),
"radeon_bl%d", dev->primary->index);
+#endif
bd = backlight_device_register(bl_name, &drm_connector->kdev,
pdata, &radeon_atom_backlight_ops, &props);
if (IS_ERR(bd)) {
-/* $OpenBSD: radeon_legacy_encoders.c,v 1.5 2017/07/01 16:14:10 kettenis Exp $ */
+/* $OpenBSD: radeon_legacy_encoders.c,v 1.6 2017/07/05 20:30:13 kettenis Exp $ */
/*
* Copyright 2007-8 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
#include "radeon.h"
#include "atom.h"
-u8 radeon_legacy_get_backlight_level(struct radeon_encoder *);
-void radeon_legacy_set_backlight_level(struct radeon_encoder *, u8);
-void radeon_legacy_backlight_init(struct radeon_encoder *);
-void radeon_add_legacy_encoder(struct drm_device *, uint32_t, uint32_t);
-
static void radeon_legacy_encoder_disable(struct drm_encoder *encoder)
{
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
memset(&props, 0, sizeof(props));
props.max_brightness = RADEON_MAX_BL_LEVEL;
props.type = BACKLIGHT_RAW;
+#ifdef __linux__
snprintf(bl_name, sizeof(bl_name),
"radeon_bl%d", dev->primary->index);
+#endif
bd = backlight_device_register(bl_name, &drm_connector->kdev,
pdata, &radeon_backlight_ops, &props);
if (IS_ERR(bd)) {