drm/radeon: add new AMD ACPI header and update relevant code
Subsystems (3)
PATCH 1/1 drm/radeon: add new AMD ACPI header and update relevant code
From: Alex Deucher <[email protected]>
Add a new header that defines the AMD ACPI interface used for laptops, PowerXpress, and chipset specific functionality and update the current code to use it.
Todo:
- properly verify the ACPI interfaces
- hook up and handle ACPI notifications
- make PX code more robust
- implement PCIe Gen and width switching using ACPI
--- drivers/gpu/drm/radeon/radeon_acpi.c | 3 +- drivers/gpu/drm/radeon/radeon_acpi.h | 439 ++++++++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_atpx_handler.c | 35 +-- 3 files changed, 455 insertions(+), 22 deletions(-) create mode 100644 drivers/gpu/drm/radeon/radeon_acpi.h
drivers/gpu/drm/radeon/radeon_acpi.c +2 -1
@@ -9,6 +9,7 @@#include "drm_sarea.h" #include "drm_crtc_helper.h" #include "radeon.h" +#include "radeon_acpi.h" #include <linux/vga_switcheroo.h>
@@ -27,7 +28,7 @@ static int radeon_atif_call(acpi_handle handle) atif_arg.pointer = &atif_arg_elements[0 ]; atif_arg_elements[0 ].type =ACPI_TYPE_INTEGER ; - atif_arg_elements[0 ].integer.value =0 ; + atif_arg_elements[0 ].integer.value =ATIF_FUNCTION_VERIFY_INTERFACE ; atif_arg_elements[1 ].type =ACPI_TYPE_INTEGER ; atif_arg_elements[1 ].integer.value =0 ;
drivers/gpu/drm/radeon/radeon_acpi.h new file +439 -0
439 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_atpx_handler.c +14 -21
@@ -12,18 +12,7 @@#include <acpi/acpi_bus.h> #include <linux/pci.h> -#define ATPX_VERSION 0 -#define ATPX_GPU_PWR 2 -#define ATPX_MUX_SELECT 3 -#define ATPX_I2C_MUX_SELECT 4 -#define ATPX_SWITCH_START 5 -#define ATPX_SWITCH_END 6 - -#define ATPX_INTEGRATED 0 -#define ATPX_DISCRETE 1 - -#define ATPX_MUX_IGD 0 -#define ATPX_MUX_DISCRETE 1 +#include "radeon_acpi.h" static struct radeon_atpx_priv { bool atpx_detected;
@@ -92,10 +81,10 @@ static int radeon_atpx_get_version(acpi_handle handle) atpx_arg.pointer = &atpx_arg_elements[0 ]; atpx_arg_elements[0 ].type =ACPI_TYPE_INTEGER ; - atpx_arg_elements[0 ].integer.value =ATPX_VERSION ; + atpx_arg_elements[0 ].integer.value =ATPX_FUNCTION_VERIFY_INTERFACE ; atpx_arg_elements[1 ].type =ACPI_TYPE_INTEGER ; - atpx_arg_elements[1 ].integer.value =ATPX_VERSION ; + atpx_arg_elements[1 ].integer.value =0 ; status =acpi_evaluate_object (handle,NULL , &atpx_arg, &buffer);if (ACPI_FAILURE (status)) {
@@ -145,27 +134,31 @@ static int radeon_atpx_execute(acpi_handle handle, int cmd_id, u16 value)static int radeon_atpx_set_discrete_state (acpi_handle handle,int state) { -return radeon_atpx_execute (handle,ATPX_GPU_PWR , state); +return radeon_atpx_execute (handle,ATPX_FUNCTION_POWER_CONTROL , state); }static int radeon_atpx_switch_mux (acpi_handle handle,int mux_id) { -return radeon_atpx_execute (handle,ATPX_MUX_SELECT , mux_id); +return radeon_atpx_execute (handle,ATPX_FUNCTION_DISPLAY_MUX_CONTROL , mux_id); }static int radeon_atpx_switch_i2c_mux (acpi_handle handle,int mux_id) { -return radeon_atpx_execute (handle,ATPX_I2C_MUX_SELECT , mux_id); +return radeon_atpx_execute (handle,ATPX_FUNCTION_I2C_MUX_CONTROL , mux_id); }static int radeon_atpx_switch_start (acpi_handle handle,int gpu_id) { -return radeon_atpx_execute (handle,ATPX_SWITCH_START , gpu_id); +return radeon_atpx_execute (handle, +ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_START_NOTIFICATION , + gpu_id); }static int radeon_atpx_switch_end (acpi_handle handle,int gpu_id) { -return radeon_atpx_execute (handle,ATPX_SWITCH_END , gpu_id); +return radeon_atpx_execute (handle, +ATPX_FUNCTION_GRAPHICS_DEVICE_SWITCH_END_NOTIFICATION , + gpu_id); }static int radeon_atpx_switchto (enum vga_switcheroo_client_id id)
@@ -173,9 +166,9 @@ static int radeon_atpx_switchto(enum vga_switcheroo_client_id id)int gpu_id;if (id ==VGA_SWITCHEROO_IGD ) - gpu_id =ATPX_INTEGRATED ; + gpu_id =ATPX_INTEGRATED_GPU ;else - gpu_id =ATPX_DISCRETE ; + gpu_id =ATPX_DISCRETE_GPU ;radeon_atpx_switch_start (radeon_atpx_priv.atpx_handle, gpu_id);radeon_atpx_switch_mux (radeon_atpx_priv.atpx_handle, gpu_id);
Signature · 1 line
1.7.7.5
Quoted 5 lines · On Wed, Jul 25, 2012 at 01:38:09PM -0400, [email protected] wrote:
From: Alex Deucher <[email protected]>
Add a new header that defines the AMD ACPI interface used for laptops, PowerXpress, and chipset specific functionality and update the current code to use it.
Great! Now my DSDT makes sense ;)
Quoted 3 lines
Todo:
- properly verify the ACPI interfaces
- hook up and handle ACPI notifications
I see a problem here, I've hacked up a standalone test module, but:
Quoted 1 line
+#define
ATIF_FUNCTION_GET_SYSTEM_PARAMETERS0x1
[...]
Quoted 4 lines
+ * flags
+ * bits 1:0:
+ * 0 -Notify(VGA, 0x81)is not used for notification
+ * 1 -Notify(VGA, 0x81)is used for notification
My system has this bit set, and the brightness control method does send the notification.
My module register itself with register_acpi_notifier and gets 2 notifications, one with ACPI_VIDEO_NOTIFY_PROBE (0x81) and the other with ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS (or DEC, depending on what I press).
The standard acpi "video" module, however, in response to ACPI_VIDEO_NOTIFY_PROBE generates a key press sending KEY_SWITCHVIDEOMODE.
This greatly confuses KDE which messes up my dual screen configuration; I guess that the spurious KEY_SWITCHVIDEOMODE may be problematic also with other DEs...
In more detail what happens is the following:
- I press the brightness hotkey, firmware generates a notification on the relevant device (_SB.PCI0.PEG0.VGA.LCD)
- ACPI video module gets the ACPI_VIDEO_NOTIFY_{DEC,INC}_BRIGHTNESS notification and tries to adjust the brightness with acpi_video_device_lcd_set_level, which in turns calls _BCM
- _BCM sets the relevant bits in the AMD-specific structure and does a Notify (VGA, 0x81)
- again ACPI video module gets the nodification (in this case ACPI_VIDEO_NOTIFY_PROBE), re-enumerated and send KEY_SWITCHVIDEOMODE
- KDE seems this and muck with the screen configuration :(
- meanwhile the brightness notification is propagated, the hypothetical radeon driver does its magic to adjust the screen.
My first idea would be to make ACPI_VIDEO_NOTIFY_PROBE also call to the acpi notifier chain, and allow the handlers to veto the key press (like it's done for ACPI_VIDEO_NOTIFY_SWITCH).
Zhang Rui what do you think about this?
The other missing bit is how to actually change the brightness... Alex, do you know what registers to poke?
My card is a:
01:00.0 VGA compatible controller [0300]: Advanced Micro Devices [AMD] nee ATI Thames XT/GL [Radeon HD 600M Series] [1002:6840]
on a Toshiba L855.
Luca
Quoted 51 lines · Luca Tettamanti
Quoted 5 lines · On Wed, Jul 25, 2012 at 01:38:09PM -0400, [email protected] wrote:
From: Alex Deucher <[email protected]>
Add a new header that defines the AMD ACPI interface used for laptops, PowerXpress, and chipset specific functionality and update the current code to use it.
Great! Now my DSDT makes sense ;)
Quoted 3 lines
Todo:
- properly verify the ACPI interfaces
- hook up and handle ACPI notificationsI see a problem here, I've hacked up a standalone test module, but:
Quoted 1 line
+#define
ATIF_FUNCTION_GET_SYSTEM_PARAMETERS0x1[...]
Quoted 4 lines
+ * flags
+ * bits 1:0:
+ * 0 -Notify(VGA, 0x81)is not used for notification
+ * 1 -Notify(VGA, 0x81)is used for notificationMy system has this bit set, and the brightness control method does send the notification.
My module register itself withregister_acpi_notifierand gets 2 notifications, one withACPI_VIDEO_NOTIFY_PROBE(0x81) and the other withACPI_VIDEO_NOTIFY_INC_BRIGHTNESS(or DEC, depending on what I press).The standard acpi "video" module, however, in response to
ACPI_VIDEO_NOTIFY_PROBEgenerates a key press sendingKEY_SWITCHVIDEOMODE.This greatly confuses KDE which messes up my dual screen configuration; I guess that the spurious
KEY_SWITCHVIDEOMODEmay be problematic also with other DEs...In more detail what happens is the following:
- I press the brightness hotkey, firmware generates a notification on the relevant device (_SB.PCI0.PEG0.VGA.LCD)
- ACPI video module gets the ACPI_VIDEO_NOTIFY_{DEC,INC}_BRIGHTNESS notification and tries to adjust the brightness withacpi_video_device_lcd_set_level, which in turns calls_BCM
-_BCMsets the relevant bits in the AMD-specific structure and does a Notify (VGA,0x81)
- again ACPI video module gets the nodification (in this caseACPI_VIDEO_NOTIFY_PROBE), re-enumerated and sendKEY_SWITCHVIDEOMODE
- KDE seems this and muck with the screen configuration :(
- meanwhile the brightness notification is propagated, the hypothetical radeon driver does its magic to adjust the screen.
Quoted 8 lines
My first idea would be to make
ACPI_VIDEO_NOTIFY_PROBEalso call to the acpi notifier chain, and allow the handlers to veto the key press (like it's done forACPI_VIDEO_NOTIFY_SWITCH).Zhang Rui what do you think about this?
The other missing bit is how to actually change the brightness... Alex, do you know what registers to poke?
You need to check if the GPU controls the backlight or the system does. I think the attached patches should point you in the right direction.
Alex
Quoted 8 lines
My card is a:
01:00.0 VGA compatible controller [0300]: Advanced Micro Devices [AMD] nee ATI Thames XT/GL [Radeon HD 600M Series] [1002:6840]
on a Toshiba L855.
Luca
From 31f6dff07ecb4cf092292345405b2151c98f0504 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Thu, 26 Jul 2012 11:32:03 -0400
Subject: [PATCH 3/3] drm/radeon: add backlight control for atom devices
On systems that use the build in GPU backlight controller, we can use atom tables to change the brightness level.
--- drivers/gpu/drm/radeon/atombios_encoders.c | 231 ++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_connectors.c | 15 -- drivers/gpu/drm/radeon/radeon_encoders.c | 18 ++- 3 files changed, 248 insertions(+), 16 deletions(-)
drivers/gpu/drm/radeon/atombios_encoders.c +231 -0
@@ -28,9 +28,238 @@#include "radeon_drm.h" #include "radeon.h" #include "atom.h" +#include <linux/backlight.h> extern int atom_debug; +#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE ) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE ) + +static u8 +radeon_atom_get_backlight_level_from_reg (struct radeon_device *rdev) +{ +u8 backlight_level; +u32 bios_2_scratch; + +if (rdev->family >=CHIP_R600 ) + bios_2_scratch =RREG32 (R600_BIOS_2_SCRATCH ); +else + bios_2_scratch =RREG32 (RADEON_BIOS_2_SCRATCH ); + + backlight_level = ((bios_2_scratch &ATOM_S2_CURRENT_BL_LEVEL_MASK ) >> +ATOM_S2_CURRENT_BL_LEVEL_SHIFT ); + +return backlight_level; +} + +static void +radeon_atom_set_backlight_level_to_reg (struct radeon_device *rdev, +u8 backlight_level) +{ +u32 bios_2_scratch; + +if (rdev->family >=CHIP_R600 ) + bios_2_scratch =RREG32 (R600_BIOS_2_SCRATCH ); +else + bios_2_scratch =RREG32 (RADEON_BIOS_2_SCRATCH ); + + bios_2_scratch &= ~ATOM_S2_CURRENT_BL_LEVEL_MASK ; + bios_2_scratch |= ((backlight_level <<ATOM_S2_CURRENT_BL_LEVEL_SHIFT ) & +ATOM_S2_CURRENT_BL_LEVEL_MASK ); + +if (rdev->family >=CHIP_R600 ) +WREG32 (R600_BIOS_2_SCRATCH , bios_2_scratch); +else +WREG32 (RADEON_BIOS_2_SCRATCH , bios_2_scratch); +} + +static void +atombios_set_panel_brightness (struct radeon_encoder *radeon_encoder) +{ +struct drm_encoder *encoder = &radeon_encoder->base; +struct drm_device *dev = radeon_encoder->base.dev; +struct radeon_device *rdev = dev->dev_private; +struct radeon_encoder_atom_dig *dig; +DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION args; +int index; + +if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT )) { + dig = radeon_encoder->enc_priv; +radeon_atom_set_backlight_level_to_reg (rdev, dig->backlight_level); + +switch (radeon_encoder->encoder_id) { +case ENCODER_OBJECT_ID_INTERNAL_LVDS : +case ENCODER_OBJECT_ID_INTERNAL_LVTM1 : + index =GetIndexIntoMasterTable (COMMAND , LCD1OutputControl); +if (dig->backlight_level ==0 ) { + args.ucAction =ATOM_LCD_BLOFF ; +atom_execute_table (rdev->mode_info.atom_context, index, (uint32_t *)&args); + }else { + args.ucAction =ATOM_LCD_BL_BRIGHTNESS_CONTROL ; +atom_execute_table (rdev->mode_info.atom_context, index, (uint32_t *)&args); + args.ucAction =ATOM_LCD_BLON ; +atom_execute_table (rdev->mode_info.atom_context, index, (uint32_t *)&args); + } +break ; +case ENCODER_OBJECT_ID_INTERNAL_UNIPHY : +case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA : +case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1 : +case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2 : +if (dig->backlight_level ==0 ) +atombios_dig_transmitter_setup (encoder,ATOM_TRANSMITTER_ACTION_LCD_BLOFF ,0 ,0 ); +else { +atombios_dig_transmitter_setup (encoder,ATOM_TRANSMITTER_ACTION_BL_BRIGHTNESS_CONTROL ,0 ,0 ); +atombios_dig_transmitter_setup (encoder,ATOM_TRANSMITTER_ACTION_LCD_BLON ,0 ,0 ); + } +break ; +default : +break ; + } + } +} + +static u8 radeon_atom_bl_level (struct backlight_device *bd) +{ +u8 level; + +/* Convert brightness to hardware level */ +if (bd->props.brightness <0 ) + level =0 ; +else if (bd->props.brightness >RADEON_MAX_BL_LEVEL ) + level =RADEON_MAX_BL_LEVEL ; +else + level = bd->props.brightness; + +return level; +} + +static int radeon_atom_backlight_update_status (struct backlight_device *bd) +{ +struct radeon_backlight_privdata *pdata =bl_get_data (bd); +struct radeon_encoder *radeon_encoder = pdata->encoder; + +if (radeon_encoder->enc_priv) { +struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; + dig->backlight_level =radeon_atom_bl_level (bd); +atombios_set_panel_brightness (radeon_encoder); + } + +return 0 ; +} + +static int radeon_atom_backlight_get_brightness (struct backlight_device *bd) +{ +struct radeon_backlight_privdata *pdata =bl_get_data (bd); +struct radeon_encoder *radeon_encoder = pdata->encoder; +struct drm_device *dev = radeon_encoder->base.dev; +struct radeon_device *rdev = dev->dev_private; + +return radeon_atom_get_backlight_level_from_reg (rdev); +} + +static const struct backlight_ops radeon_atom_backlight_ops = { + .get_brightness = radeon_atom_backlight_get_brightness, + .update_status = radeon_atom_backlight_update_status, +}; + +void radeon_atom_backlight_init (struct radeon_encoder *radeon_encoder, +struct drm_connector *drm_connector) +{ +struct drm_device *dev = radeon_encoder->base.dev; +struct radeon_device *rdev = dev->dev_private; +struct backlight_device *bd; +struct backlight_properties props; +struct radeon_backlight_privdata *pdata; +struct radeon_encoder_atom_dig *dig; +u8 backlight_level; + +if (!radeon_encoder->enc_priv) +return ; + +if (!rdev->is_atom_bios) +return ; + +if (!rdev->mode_info.gpu_controls_bl) +return ; + + pdata =kmalloc (sizeof (struct radeon_backlight_privdata ),GFP_KERNEL ); +if (!pdata) { +DRM_ERROR ("Memory allocation failed\n" ); + goto error; + } + +memset (&props,0 ,sizeof (props)); + props.max_brightness =RADEON_MAX_BL_LEVEL ; + props.type =BACKLIGHT_RAW ; + bd =backlight_device_register ("radeon_bl" , &drm_connector->kdev, + pdata, &radeon_atom_backlight_ops, &props); +if (IS_ERR (bd)) { +DRM_ERROR ("Backlight registration failed\n" ); + goto error; + } + + pdata->encoder = radeon_encoder; + + backlight_level =radeon_atom_get_backlight_level_from_reg (rdev); + + dig = radeon_encoder->enc_priv; + dig->bl_dev = bd; + + bd->props.brightness =radeon_atom_backlight_get_brightness (bd); + bd->props.power =FB_BLANK_UNBLANK ; +backlight_update_status (bd); + +DRM_INFO ("radeon atom DIG backlight initialized\n" ); + +return ; + +error: +kfree (pdata); +return ; +} + +static void radeon_atom_backlight_exit (struct radeon_encoder *radeon_encoder) +{ +struct drm_device *dev = radeon_encoder->base.dev; +struct radeon_device *rdev = dev->dev_private; +struct backlight_device *bd =NULL ; +struct radeon_encoder_atom_dig *dig; + +if (!radeon_encoder->enc_priv) +return ; + +if (!rdev->is_atom_bios) +return ; + +if (!rdev->mode_info.gpu_controls_bl) +return ; + + dig = radeon_encoder->enc_priv; + bd = dig->bl_dev; + dig->bl_dev =NULL ; + +if (bd) { +struct radeon_legacy_backlight_privdata *pdata; + + pdata =bl_get_data (bd); +backlight_device_unregister (bd); +kfree (pdata); + +DRM_INFO ("radeon atom LVDS backlight unloaded\n" ); + } +} + +#else /* !CONFIG_BACKLIGHT_CLASS_DEVICE */ + +void radeon_atom_backlight_init (struct radeon_encoder *encoder) +{ +} + +static void radeon_atom_backlight_exit (struct radeon_encoder *encoder) +{ +} + +#endif +/* evil but including atombios.h is much worse */ bool radeon_atom_get_tv_timings (struct radeon_device *rdev,int index,struct drm_display_mode *mode);
@@ -2272,6 +2501,8 @@ static const struct drm_encoder_helper_funcs radeon_atom_dac_helper_funcs = {void radeon_enc_destroy (struct drm_encoder *encoder) {struct radeon_encoder *radeon_encoder =to_radeon_encoder (encoder); +if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT )) +radeon_atom_backlight_exit (radeon_encoder);kfree (radeon_encoder->enc_priv);drm_encoder_cleanup (encoder);kfree (radeon_encoder);
drivers/gpu/drm/radeon/radeon_connectors.c +0 -15
@@ -40,10 +40,6 @@ radeon_atombios_connected_scratch_regs(struct drm_connector *connector,struct drm_encoder *encoder, bool connected); -extern void -radeon_legacy_backlight_init (struct radeon_encoder *radeon_encoder, -struct drm_connector *drm_connector); -void radeon_connector_hotplug (struct drm_connector *connector) {struct drm_device *dev = connector->dev;
@@ -2008,15 +2004,4 @@ radeon_add_legacy_connector(struct drm_device *dev, connector->polled =DRM_CONNECTOR_POLL_HPD ; connector->display_info.subpixel_order = subpixel_order;drm_sysfs_connector_add (connector); -if (connector_type ==DRM_MODE_CONNECTOR_LVDS ) { -struct drm_encoder *drm_encoder; - -list_for_each_entry (drm_encoder, &dev->mode_config.encoder_list, head) { -struct radeon_encoder *radeon_encoder; - - radeon_encoder =to_radeon_encoder (drm_encoder); -if (radeon_encoder->encoder_id ==ENCODER_OBJECT_ID_INTERNAL_LVDS ) -radeon_legacy_backlight_init (radeon_encoder, connector); - } - } }
drivers/gpu/drm/radeon/radeon_encoders.c +17 -1
@@ -29,6 +29,14 @@#include "radeon.h" #include "atom.h" +extern void +radeon_legacy_backlight_init (struct radeon_encoder *radeon_encoder, +struct drm_connector *drm_connector); +extern void +radeon_atom_backlight_init (struct radeon_encoder *radeon_encoder, +struct drm_connector *drm_connector); + +static uint32_t radeon_encoder_clones (struct drm_encoder *encoder) {struct drm_device *dev = encoder->dev;
@@ -153,6 +161,7 @@ radeon_get_encoder_enum(struct drm_device *dev, uint32_t supported_device, uint8void radeon_link_encoder_connector (struct drm_device *dev) { +struct radeon_device *rdev = dev->dev_private;struct drm_connector *connector;struct radeon_connector *radeon_connector;struct drm_encoder *encoder;
@@ -163,8 +172,15 @@ radeon_link_encoder_connector(struct drm_device *dev) radeon_connector =to_radeon_connector (connector);list_for_each_entry (encoder, &dev->mode_config.encoder_list, head) { radeon_encoder =to_radeon_encoder (encoder); -if (radeon_encoder->devices & radeon_connector->devices) +if (radeon_encoder->devices & radeon_connector->devices) {drm_mode_connector_attach_encoder (connector, encoder); +if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT )) { +if (rdev->is_atom_bios) +radeon_atom_backlight_init (radeon_encoder, connector); +else +radeon_legacy_backlight_init (radeon_encoder, connector); + } + } } } }
Signature · 1 line
1.7.7.5
From f55f2a468c48494b8111bf732a9f8d3586d8541e Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Thu, 26 Jul 2012 11:05:22 -0400
Subject: [PATCH 2/3] drm/radeon: rework legacy backlight control
To better enable sharing with atom backlight control.
--- drivers/gpu/drm/radeon/radeon_legacy_encoders.c | 19 ++++++------------- drivers/gpu/drm/radeon/radeon_mode.h | 11 +++++++++++ 2 files changed, 17 insertions(+), 13 deletions(-)
drivers/gpu/drm/radeon/radeon_legacy_encoders.c +6 -13
@@ -271,13 +271,6 @@ static const struct drm_encoder_helper_funcs radeon_legacy_lvds_helper_funcs = {#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE ) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE ) -#define MAX_RADEON_LEVEL 0xFF - -struct radeon_backlight_privdata { -struct radeon_encoder *encoder; -uint8_t negative; -}; -static uint8_t radeon_legacy_lvds_level (struct backlight_device *bd) {struct radeon_backlight_privdata *pdata =bl_get_data (bd);
@@ -286,13 +279,13 @@ static uint8_t radeon_legacy_lvds_level(struct backlight_device *bd)/* Convert brightness to hardware level */ if (bd->props.brightness <0 ) level =0 ; -else if (bd->props.brightness >MAX_RADEON_LEVEL ) - level =MAX_RADEON_LEVEL ; +else if (bd->props.brightness >RADEON_MAX_BL_LEVEL ) + level =RADEON_MAX_BL_LEVEL ;else level = bd->props.brightness;if (pdata->negative) - level =MAX_RADEON_LEVEL - level; + level =RADEON_MAX_BL_LEVEL - level;return level; }
@@ -336,7 +329,7 @@ static int radeon_legacy_backlight_get_brightness(struct backlight_device *bd) backlight_level = (RREG32 (RADEON_LVDS_GEN_CNTL ) >>RADEON_LVDS_BL_MOD_LEVEL_SHIFT ) &0xff ; -return pdata->negative ?MAX_RADEON_LEVEL - backlight_level : backlight_level; +return pdata->negative ?RADEON_MAX_BL_LEVEL - backlight_level : backlight_level; }static const struct backlight_ops radeon_backlight_ops = {
@@ -370,7 +363,7 @@ void radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder, }memset (&props,0 ,sizeof (props)); - props.max_brightness =MAX_RADEON_LEVEL ; + props.max_brightness =RADEON_MAX_BL_LEVEL ; props.type =BACKLIGHT_RAW ; bd =backlight_device_register ("radeon_bl" , &drm_connector->kdev, pdata, &radeon_backlight_ops, &props);
@@ -449,7 +442,7 @@ static void radeon_legacy_backlight_exit(struct radeon_encoder *radeon_encoder) }if (bd) { -struct radeon_legacy_backlight_privdata *pdata; +struct radeon_backlight_privdata *pdata; pdata =bl_get_data (bd);backlight_device_unregister (bd);
drivers/gpu/drm/radeon/radeon_mode.h +11 -0
@@ -256,6 +256,17 @@ struct radeon_mode_info {bool gpu_controls_bl; }; +#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE ) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE ) + +#define RADEON_MAX_BL_LEVEL 0xFF + +struct radeon_backlight_privdata { +struct radeon_encoder *encoder; +uint8_t negative; +}; + +#endif +#define MAX_H_CODE_TIMING_LEN 32#define MAX_V_CODE_TIMING_LEN 32
Signature · 1 line
1.7.7.5
From a56ac560e34032ca803e0909c8a92a9037046790 Mon Sep 17 00:00:00 2001
From: Alex Deucher <[email protected]>
Date: Thu, 26 Jul 2012 09:50:57 -0400
Subject: [PATCH 1/3] drm/radeon: track whether the GPU controls the backlight
A table in the vbios tells us whether the GPU backlight controller is used or not. If the bit is set, the GPU backlight controller is used; if it is not set, an off-chip backlight controller is used.
--- drivers/gpu/drm/radeon/radeon_atombios.c | 4 ++++ drivers/gpu/drm/radeon/radeon_mode.h | 2 ++ 2 files changed, 6 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_atombios.c +4 -0
@@ -1254,6 +1254,10 @@ bool radeon_atom_get_clock_info(struct drm_device *dev)if (rdev->clock.max_pixel_clock ==0 ) rdev->clock.max_pixel_clock =40000 ; +/* not technically a clock, but... */ +if (firmware_info->info.usFirmwareCapability.sbfAccess.GPUControlsBL) + rdev->mode_info.gpu_controls_bl = true; +return true; }
drivers/gpu/drm/radeon/radeon_mode.h +2 -0
@@ -252,6 +252,8 @@ struct radeon_mode_info {/* pointer to fbdev info structure */ struct radeon_fbdev *rfbdev; +/* GPU controls backlight */ +bool gpu_controls_bl; };#define MAX_H_CODE_TIMING_LEN 32
Signature · 1 line
1.7.7.5
Quoted 7 lines · Alex Deucher
Quoted 2 lines · Luca Tettamanti
The other missing bit is how to actually change the brightness... Alex, do you know what registers to poke?
You need to check if the GPU controls the backlight or the system does. I think the attached patches should point you in the right direction.
Yep :)
0050: ATOM_FIRMWARE_CAPABILITY_ACCESS usFirmwareCapability :
0050: (union) ATOM_FIRMWARE_CAPABILITY sbfAccess :
USHORT GPUControlsBL:1 = 0x0001 (1)
The panel is using the INTERNAL_UNIPHY encoder, and I see the UNIPHYTransmitterControl command table.
Interaction with video.ko is still a bit messy...
Do you already have code for handling the notifications? I'll work on it in the weekend otherwise ;)
Luca
Quoted 15 lines · Luca Tettamanti
Quoted 7 lines · Alex Deucher
Quoted 2 lines · Luca Tettamanti
The other missing bit is how to actually change the brightness... Alex, do you know what registers to poke?
You need to check if the GPU controls the backlight or the system does. I think the attached patches should point you in the right direction.
Yep :)
0050:
ATOM_FIRMWARE_CAPABILITY_ACCESSusFirmwareCapability :
0050: (union)ATOM_FIRMWARE_CAPABILITYsbfAccess :USHORT GPUControlsBL:1 = 0x0001 (1)
Quoted 7 lines
The panel is using the
INTERNAL_UNIPHYencoder, and I see the UNIPHYTransmitterControl command table.Interaction with video.ko is still a bit messy...
Do you already have code for handling the notifications? I'll work on it in the weekend otherwise ;)
I don't have patches for that. Please feel free to work on it :)
Thanks,
Alex
Quoted 19 lines · Alex Deucher
Quoted 18 lines · Luca Tettamanti
Quoted 7 lines · Alex Deucher
Quoted 2 lines · Luca Tettamanti
The other missing bit is how to actually change the brightness... Alex, do you know what registers to poke?
You need to check if the GPU controls the backlight or the system does. I think the attached patches should point you in the right direction.
Yep :)
0050:
ATOM_FIRMWARE_CAPABILITY_ACCESSusFirmwareCapability :
0050: (union)ATOM_FIRMWARE_CAPABILITYsbfAccess :USHORT GPUControlsBL:1 = 0x0001 (1)The panel is using the
INTERNAL_UNIPHYencoder, and I see the UNIPHYTransmitterControl command table.
Quoted 6 lines
Quoted 4 lines
Interaction with video.ko is still a bit messy...
Do you already have code for handling the notifications? I'll work on it in the weekend otherwise ;)
I don't have patches for that. Please feel free to work on it :)
One thing worth checking, the sbios may write the requested backlight level to the bios scratch reg, in which case the driver only has to execute the BL_BRIGHTNESS action rather than writing the requested level to the register first.
Alex
Quoted 4 lines
Thanks,
Alex
Quoted 19 lines · Alex Deucher
Quoted 18 lines · Luca Tettamanti
Quoted 7 lines · Alex Deucher
Quoted 2 lines · Luca Tettamanti
The other missing bit is how to actually change the brightness... Alex, do you know what registers to poke?
You need to check if the GPU controls the backlight or the system does. I think the attached patches should point you in the right direction.
Yep :)
0050:
ATOM_FIRMWARE_CAPABILITY_ACCESSusFirmwareCapability :
0050: (union)ATOM_FIRMWARE_CAPABILITYsbfAccess :USHORT GPUControlsBL:1 = 0x0001 (1)The panel is using the
INTERNAL_UNIPHYencoder, and I see the UNIPHYTransmitterControl command table.
Quoted 6 lines
Quoted 4 lines
Interaction with video.ko is still a bit messy...
Do you already have code for handling the notifications? I'll work on it in the weekend otherwise ;)
I don't have patches for that. Please feel free to work on it :)
I just found the first problem (probably a BIOS bug):ATIF_FUNCTION_GET_SYSTEM_PARAMETERS is implemented in the DSDT, but the corresponding bit ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED is not set :( I intended to use the method to set up the notification handler but now my BIOS says that it's not there even if it is...
Can I assume some default values (e.g. notifications are enabled and will use 0x81 unless ATIF_FUNCTION_GET_SYSTEM_PARAMETERS says something different)?
thanks,
Luca
Quoted 27 lines · Luca Tettamanti
Quoted 19 lines · Alex Deucher
Quoted 18 lines · Luca Tettamanti
Quoted 7 lines · Alex Deucher
Quoted 2 lines · Luca Tettamanti
The other missing bit is how to actually change the brightness... Alex, do you know what registers to poke?
You need to check if the GPU controls the backlight or the system does. I think the attached patches should point you in the right direction.
Yep :)
0050:
ATOM_FIRMWARE_CAPABILITY_ACCESSusFirmwareCapability :
0050: (union)ATOM_FIRMWARE_CAPABILITYsbfAccess :USHORT GPUControlsBL:1 = 0x0001 (1)The panel is using the
INTERNAL_UNIPHYencoder, and I see the UNIPHYTransmitterControl command table.Quoted 6 lines
Quoted 4 lines
Interaction with video.ko is still a bit messy...
Do you already have code for handling the notifications? I'll work on it in the weekend otherwise ;)
I don't have patches for that. Please feel free to work on it :)
Quoted 8 lines
I just found the first problem (probably a BIOS bug):
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSis implemented in the DSDT, but the corresponding bitATIF_GET_SYSTEM_PARAMETERS_SUPPORTEDis not set :( I intended to use the method to set up the notification handler but now my BIOS says that it's not there even if it is...
Can I assume some default values (e.g. notifications are enabled and will use0x81unlessATIF_FUNCTION_GET_SYSTEM_PARAMETERSsays something different)?
The spec says that the bits in the supported functions vector mean that if bit n is set, function n+1 exists, but it's possible that the spec is wrong and it's actually a 1 to 1 mapping; if bit n is set, function n is supported. In which case the the supported functions vector bits should be:
+/* supported functions vector */
+# define ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED (1 << 1) +# define ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED (1 << 2) +# define ATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED (1 << 3) +# define ATIF_GET_LID_STATE_SUPPORTED (1 << 4) +# define ATIF_GET_TV_STANDARD_FROM_CMOS_SUPPORTED (1 << 5) +# define ATIF_SET_TV_STANDARD_IN_CMOS_SUPPORTED (1 << 6) +# define ATIF_GET_PANEL_EXPANSION_MODE_FROM_CMOS_SUPPORTED (1 << 7) +# define ATIF_SET_PANEL_EXPANSION_MODE_IN_CMOS_SUPPORTED (1 << 8) +# define ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED (1 << 13) +# define ATIF_GET_GRAPHICS_DEVICE_TYPES_SUPPORTED (1 << 15)
See if that lines up better. I'm still new to these ACPI interfaces so I'm not an expert yet.
Alex
Quoted 10 lines · Alex Deucher
Quoted 8 lines · Luca Tettamanti
I just found the first problem (probably a BIOS bug):
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSis implemented in the DSDT, but the corresponding bitATIF_GET_SYSTEM_PARAMETERS_SUPPORTEDis not set :( I intended to use the method to set up the notification handler but now my BIOS says that it's not there even if it is...
Can I assume some default values (e.g. notifications are enabled and will use0x81unlessATIF_FUNCTION_GET_SYSTEM_PARAMETERSsays something different)?
Quoted 2 lines
The spec says that the bits in the supported functions vector mean that if bit n is set, function n+1 exists,
Hum, I don't follow. The vector in my case is 0x2 (1 << 1), that would mean that ATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED (1 << 2) is supported?
Maybe if the bit n is set then functions 0..n are available? That would (almost) match what I see...
Quoted 16 lines
but it's possible that the
spec is wrong and it's actually a 1 to 1 mapping; if bit n is set, function n is supported. In which case the the supported functions vector bits should be:(quoted diff) +11
-0+/* supported functions vector */ +# define ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED (1 << 1) +# define ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED (1 << 2) +# define ATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED (1 << 3) +# define ATIF_GET_LID_STATE_SUPPORTED (1 << 4) +# define ATIF_GET_TV_STANDARD_FROM_CMOS_SUPPORTED (1 << 5) +# define ATIF_SET_TV_STANDARD_IN_CMOS_SUPPORTED (1 << 6) +# define ATIF_GET_PANEL_EXPANSION_MODE_FROM_CMOS_SUPPORTED (1 << 7) +# define ATIF_SET_PANEL_EXPANSION_MODE_IN_CMOS_SUPPORTED (1 << 8) +# define ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED (1 << 13) +# define ATIF_GET_GRAPHICS_DEVICE_TYPES_SUPPORTED (1 << 15)
Quoted 1 line
See if that lines up better.
Not really... the value returned by VERIFY_INTERFACE is 0x2, but in the DSDT I see:
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTSATIF_FUNCTION_GET_TV_STANDARD_FROM_CMOSATIF_FUNCTION_SET_TV_STANDARD_IN_CMOS
The implementation of the first one makes sense, the second is used for brightness control. The other two _might_ be a leftover (the machine does not have an analog TV out).
Quoted 2 lines
I'm still new to these ACPI interfaces
so I'm not an expert yet.
I've been exposed to a lot of ACPI code (I wrote the asus_atk0110 driver), in my experience the DSDT is full of crap: code copied&pasted from other machines, leftover no longer used, and other stuff that's plainly wrong.
Luca
Quoted 14 lines · Luca Tettamanti
Quoted 10 lines · Alex Deucher
Quoted 8 lines · Luca Tettamanti
I just found the first problem (probably a BIOS bug):
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSis implemented in the DSDT, but the corresponding bitATIF_GET_SYSTEM_PARAMETERS_SUPPORTEDis not set :( I intended to use the method to set up the notification handler but now my BIOS says that it's not there even if it is...
Can I assume some default values (e.g. notifications are enabled and will use0x81unlessATIF_FUNCTION_GET_SYSTEM_PARAMETERSsays something different)?Quoted 2 lines
The spec says that the bits in the supported functions vector mean that if bit n is set, function n+1 exists,
Quoted 7 lines
Hum, I don't follow. The vector in my case is
0x2(1 << 1), that would mean thatATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED(1 << 2) is supported?Maybe if the bit n is set then functions 0..n are available? That would (almost) match what I see...
From the spec:
Supported DWORD Bit vector providing supported functions
information. Each bit marks
Functions Bit support for one specific function of the
ATIF method. Bit n, if set,
Vector indicates that Function n+1 is supported.
I don't know how wonky bioses in the wild are however. I can see what our internal teams do in these sort of cases.
Quoted 22 lines
Quoted 17 lines
but it's possible that the
spec is wrong and it's actually a 1 to 1 mapping; if bit n is set, function n is supported. In which case the the supported functions vector bits should be:(quoted diff) +11
-0+/* supported functions vector */ +# define ATIF_GET_SYSTEM_PARAMETERS_SUPPORTED (1 << 1) +# define ATIF_GET_SYSTEM_BIOS_REQUESTS_SUPPORTED (1 << 2) +# define ATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED (1 << 3) +# define ATIF_GET_LID_STATE_SUPPORTED (1 << 4) +# define ATIF_GET_TV_STANDARD_FROM_CMOS_SUPPORTED (1 << 5) +# define ATIF_SET_TV_STANDARD_IN_CMOS_SUPPORTED (1 << 6) +# define ATIF_GET_PANEL_EXPANSION_MODE_FROM_CMOS_SUPPORTED (1 << 7) +# define ATIF_SET_PANEL_EXPANSION_MODE_IN_CMOS_SUPPORTED (1 << 8) +# define ATIF_TEMPERATURE_CHANGE_NOTIFICATION_SUPPORTED (1 << 13) +# define ATIF_GET_GRAPHICS_DEVICE_TYPES_SUPPORTED (1 << 15)Quoted 1 line
See if that lines up better.
Not really... the value returned by
VERIFY_INTERFACEis0x2, but in the DSDT I see:
Quoted 8 lines
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTSATIF_FUNCTION_GET_TV_STANDARD_FROM_CMOSATIF_FUNCTION_SET_TV_STANDARD_IN_CMOSThe implementation of the first one makes sense, the second is used for brightness control. The other two _might_ be a leftover (the machine does not have an analog TV out).
Yeah, probably unless there is a TV-out on a docking station or something like that. The TV-out port should show up in the connector table in the vbios even if it has a port on the docking station however.
Alex
Quoted 21 lines · Alex Deucher
Quoted 11 lines · Luca Tettamanti
Quoted 10 lines · Alex Deucher
Quoted 8 lines · Luca Tettamanti
I just found the first problem (probably a BIOS bug):
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSis implemented in the DSDT, but the corresponding bitATIF_GET_SYSTEM_PARAMETERS_SUPPORTEDis not set :( I intended to use the method to set up the notification handler but now my BIOS says that it's not there even if it is...
Can I assume some default values (e.g. notifications are enabled and will use0x81unlessATIF_FUNCTION_GET_SYSTEM_PARAMETERSsays something different)?Quoted 8 lines
Quoted 2 lines
The spec says that the bits in the supported functions vector mean that if bit n is set, function n+1 exists,
Hum, I don't follow. The vector in my case is
0x2(1 << 1), that would mean thatATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED(1 << 2) is supported?Maybe if the bit n is set then functions 0..n are available? That would (almost) match what I see...
Quoted 7 lines
From the spec:
Supported DWORD Bit vector providing supported functions
information. Each bit marks
Functions Bit support for one specific function of the
ATIF method. Bit n, if set,
Vector indicates that Function n+1 is supported.
Sorry, I still don't understand it... what's "Function n+1" in this context?
Does this mean that if bit n is set then the function defined as 1 << (n+1) is supported?
Quoted 2 lines
I don't know how wonky bioses in the wild are however. I can see what our internal teams do in these sort of cases.
That would be helpful :)
Note that on this machine (Toshiba L855-10W) brightness control under windows does not work with the stock catalyst driver, it works only with the (oldish) driver supplied by Toshiba.
Anyway, I'm attaching v2 of my patches, I've incorporated the suggestions and some bits of code from joeyli, and now brightness control is actually implemented.
Still missing is the issue of event 0x81 and the conflict with video.ko; the handler should probably return NOTIFY_BAD to veto the keypress.
Luca
Quoted 1 line
From
f0f8699eabee0d47b93fba14f8126b821cc106a5Mon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Sun, 29 Jul 2012 17:04:43 +0200
Subject: [PATCH 1/4] drm/radeon: refactor radeon_atif_call
Don't hard-code function number, this will allow to reuse the function.
v2: add support for the 2nd parameter (from Lee, Chun-Yi <[email protected]>).
--- drivers/gpu/drm/radeon/radeon_acpi.c | 38 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-)
drivers/gpu/drm/radeon/radeon_acpi.c +23 -15
@@ -14,23 +14,30 @@#include <linux/vga_switcheroo.h> /* Call the ATIF method -* -* Note: currently we discard the output */ -static int radeon_atif_call (acpi_handle handle) +static union acpi_object *radeon_atif_call (acpi_handle handle,int function, +struct acpi_buffer *params) {acpi_status status;union acpi_object atif_arg_elements[2 ];struct acpi_object_list atif_arg; -struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; atif_arg.count =2 ; atif_arg.pointer = &atif_arg_elements[0 ]; atif_arg_elements[0 ].type =ACPI_TYPE_INTEGER ; - atif_arg_elements[0 ].integer.value =ATIF_FUNCTION_VERIFY_INTERFACE ; - atif_arg_elements[1 ].type =ACPI_TYPE_INTEGER ; - atif_arg_elements[1 ].integer.value =0 ; + atif_arg_elements[0 ].integer.value = function; + +if (params) { + atif_arg_elements[1 ].type =ACPI_TYPE_BUFFER ; + atif_arg_elements[1 ].buffer.length = params->length; + atif_arg_elements[1 ].buffer.pointer = params->pointer; + }else { +/* We need a second fake parameter */ + atif_arg_elements[1 ].type =ACPI_TYPE_INTEGER ; + atif_arg_elements[1 ].integer.value =0 ; + } status =acpi_evaluate_object (handle,"ATIF" , &atif_arg, &buffer);
@@ -39,18 +46,18 @@ static int radeon_atif_call(acpi_handle handle)DRM_DEBUG_DRIVER ("failed to evaluate ATIF got %s\n" ,acpi_format_exception (status));kfree (buffer.pointer); -return 1 ; +return NULL ; } -kfree (buffer.pointer); -return 0 ; +return buffer.pointer; }/* Call all ACPI methods here */ int radeon_acpi_init (struct radeon_device *rdev) {acpi_handle handle; -int ret; +union acpi_object *info; +int ret =0 ;/* Get the device handle */ handle =DEVICE_ACPI_HANDLE (&rdev->pdev->dev);
@@ -60,10 +67,11 @@ int radeon_acpi_init(struct radeon_device *rdev)return 0 ;/* Call the ATIF method */ - ret =radeon_atif_call (handle); -if (ret) -return ret; + info =radeon_atif_call (handle,ATIF_FUNCTION_VERIFY_INTERFACE ,NULL ); +if (!info) + ret = -EIO ; -return 0 ; +kfree (info); +return ret; }
Signature · 1 line
1.7.10.4
Quoted 1 line
From
427002ddf653b0abd0fb820b09322bf2a0b281afMon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Mon, 30 Jul 2012 21:11:58 +0200
Subject: [PATCH 2/4] drm/radeon: implement radeon_atif_verify_interface
Wrap the call to VERIFY_INTERFACE and add the parsing of the support vectors.
v2: use a packed struct for handling the output of ACPI calls, hides ugly pointer arithmetics (Lee, Chun-Yi <[email protected]>).
--- drivers/gpu/drm/radeon/radeon.h | 40 +++++++++++++++++ drivers/gpu/drm/radeon/radeon_acpi.c | 79 +++++++++++++++++++++++++++++++--- 2 files changed, 113 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon.h +40 -0
@@ -1456,6 +1456,44 @@ struct r600_vram_scratch {u64 gpu_addr; }; +/* +* ACPI +*/ +struct radeon_atif_notification_cfg { +bool enabled; +int command_code; +}; + +struct radeon_atif_notifications { +bool display_switch; +bool expansion_mode_change; +bool thermal_state; +bool forced_power_state; +bool system_power_state; +bool display_conf_change; +bool px_gfx_switch; +bool brightness_change; +bool dgpu_display_event; +}; + +struct radeon_atif_functions { +bool system_params; +bool sbios_requests; +bool select_active_disp; +bool lid_state; +bool get_tv_standard; +bool set_tv_standard; +bool get_panel_expansion_mode; +bool set_panel_expansion_mode; +bool temperature_change; +bool graphics_device_types; +}; + +struct radeon_atif { +struct radeon_atif_notifications notifications; +struct radeon_atif_functions functions; +struct radeon_atif_notification_cfg notification_cfg; +};/* * Core structure, functions and helpers.
@@ -1548,6 +1586,8 @@ struct radeon_device {unsigned debugfs_count;/* virtual memory */ struct radeon_vm_manager vm_manager; +/* ACPI interface */ +struct radeon_atif atif; }; int radeon_device_init(struct radeon_device *rdev,
drivers/gpu/drm/radeon/radeon_acpi.c +73 -6
102 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 1 line
From
e83d04d1b60c5cf46611f6afc9680024e1dad73bMon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Mon, 30 Jul 2012 21:16:06 +0200
Subject: [PATCH 3/4] drm/radeon: implement wrapper for GET_SYSTEM_PARAMS
Use GET_SYSTEM_PARAMS for retrieving the configuration for the system BIOS notifications.
v2: packed struct (Lee, Chun-Yi <[email protected]>)
--- drivers/gpu/drm/radeon/radeon_acpi.c | 84 +++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_acpi.c +82 -2
108 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 1 line
From
1d48218e22427dbeeca3e31fd18c78c4fbd35969Mon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Mon, 30 Jul 2012 21:20:35 +0200
Subject: [PATCH 4/4] drm/radeon: implement handler for ACPI event
Set up an handler for ACPI events and respond to brightness change requests from the system BIOS.
--- drivers/gpu/drm/radeon/atombios_encoders.c | 2 +- drivers/gpu/drm/radeon/radeon_acpi.c | 119 +++++++++++++++++++++++++++- drivers/gpu/drm/radeon/radeon_acpi.h | 6 ++ drivers/gpu/drm/radeon/radeon_mode.h | 2 + drivers/gpu/drm/radeon/radeon_pm.c | 4 +- 5 files changed, 127 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/atombios_encoders.c +1 -1
@@ -72,7 +72,7 @@ radeon_atom_set_backlight_level_to_reg(struct radeon_device *rdev,WREG32 (RADEON_BIOS_2_SCRATCH , bios_2_scratch); } -static void +void atombios_set_panel_brightness (struct radeon_encoder *radeon_encoder) {struct drm_encoder *encoder = &radeon_encoder->base;
drivers/gpu/drm/radeon/radeon_acpi.c +115 -4
149 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_acpi.h +6 -0
@@ -24,6 +24,12 @@#ifndef RADEON_ACPI_H #define RADEON_ACPI_H +struct radeon_device ; +struct acpi_bus_event ; + +int radeon_atif_handler (struct radeon_device *rdev, +struct acpi_bus_event *event); +/* AMD hw uses four ACPI control methods: * 1. ATIF * ARG0: (ACPI_INTEGER) function code
drivers/gpu/drm/radeon/radeon_mode.h +2 -0
@@ -697,6 +697,8 @@ void radeon_panel_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *adjusted_mode);void atom_rv515_force_tv_scaler (struct radeon_device *rdev,struct radeon_crtc *radeon_crtc); +void atombios_set_panel_brightness (struct radeon_encoder *radeon_encoder); +/* legacy tv */ void radeon_legacy_tv_adjust_crtc_reg(struct drm_encoder *encoder, uint32_t *h_total_disp, uint32_t *h_sync_strt_wid,
drivers/gpu/drm/radeon/radeon_pm.c +3 -1
@@ -22,6 +22,7 @@*/ #include "drmP.h" #include "radeon.h" +#include "radeon_acpi.h" #include "avivod.h" #include "atom.h" #ifdef CONFIG_ACPI
@@ -95,7 +96,8 @@ static int radeon_acpi_event(struct notifier_block *nb, } } -return NOTIFY_OK ; +/* Check for pending SBIOS requests */ +return radeon_atif_handler (rdev, entry); }#endif
Signature · 1 line
1.7.10.4
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 30 lines · Luca Tettamanti
Quoted 21 lines · Alex Deucher
Quoted 11 lines · Luca Tettamanti
Quoted 10 lines · Alex Deucher
Quoted 8 lines · Luca Tettamanti
I just found the first problem (probably a BIOS bug):
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSis implemented in the DSDT, but the corresponding bitATIF_GET_SYSTEM_PARAMETERS_SUPPORTEDis not set :( I intended to use the method to set up the notification handler but now my BIOS says that it's not there even if it is...
Can I assume some default values (e.g. notifications are enabled and will use0x81unlessATIF_FUNCTION_GET_SYSTEM_PARAMETERSsays something different)?Quoted 8 lines
Quoted 2 lines
The spec says that the bits in the supported functions vector mean that if bit n is set, function n+1 exists,
Hum, I don't follow. The vector in my case is
0x2(1 << 1), that would mean thatATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED(1 << 2) is supported?Maybe if the bit n is set then functions 0..n are available? That would (almost) match what I see...
Quoted 7 lines
From the spec:
Supported DWORD Bit vector providing supported functions
information. Each bit marks
Functions Bit support for one specific function of the
ATIF method. Bit n, if set,
Vector indicates that Function n+1 is supported.
Quoted 4 lines
Sorry, I still don't understand it... what's "Function n+1" in this context?
Does this mean that if bit n is set then the function defined as 1 << (n+1) is supported?
It means if bit n is set in teh supported function vector, function n+1 is supported. E.g., if bit 1 is set, function 2 (ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS) is supported. If bit 3 is set function 4 (ATIF_FUNCTION_GET_LID_STATE) is supported, etc.
Alex
Quoted 17 lines
Quoted 3 lines
I don't know how wonky bioses in the wild are however. I can see what our internal teams do in these sort of cases.
That would be helpful :)
Note that on this machine (Toshiba L855-10W) brightness control under windows does not work with the stock catalyst driver, it works only with the (oldish) driver supplied by Toshiba.Anyway, I'm attaching v2 of my patches, I've incorporated the suggestions and some bits of code from joeyli, and now brightness control is actually implemented.
Still missing is the issue of event
0x81and the conflict with video.ko; the handler should probably returnNOTIFY_BADto veto the keypress.Luca
Quoted 13 lines · Alex Deucher
Quoted 11 lines · Luca Tettamanti
Quoted 5 lines · Alex Deucher
Supported DWORD Bit vector providing supported functions
information. Each bit marks
Functions Bit support for one specific function of the
ATIF method. Bit n, if set,
Vector indicates that Function n+1 is supported.Sorry, I still don't understand it... what's "Function n+1" in this context?
Does this mean that if bit n is set then the function defined as 1 << (n+1) is supported?
Quoted 4 lines
It means if bit n is set in teh supported function vector, function n+1 is supported. E.g., if bit 1 is set, function 2 (
ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS) is supported. If bit 3 is set function 4 (ATIF_FUNCTION_GET_LID_STATE) is supported, etc.
Great, just had an epiphany ;-) "n+1" refers to the value that's passed down to ATIF, I was still thinking in terms of bitmasks... Ok, so my code is correct, BIOS is botched... meh.
L
Quoted 38 lines · Luca Tettamanti
Quoted 21 lines · Alex Deucher
Quoted 11 lines · Luca Tettamanti
Quoted 10 lines · Alex Deucher
Quoted 8 lines · Luca Tettamanti
I just found the first problem (probably a BIOS bug):
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSis implemented in the DSDT, but the corresponding bitATIF_GET_SYSTEM_PARAMETERS_SUPPORTEDis not set :( I intended to use the method to set up the notification handler but now my BIOS says that it's not there even if it is...
Can I assume some default values (e.g. notifications are enabled and will use0x81unlessATIF_FUNCTION_GET_SYSTEM_PARAMETERSsays something different)?Quoted 8 lines
Quoted 2 lines
The spec says that the bits in the supported functions vector mean that if bit n is set, function n+1 exists,
Hum, I don't follow. The vector in my case is
0x2(1 << 1), that would mean thatATIF_SELECT_ACTIVE_DISPLAYS_SUPPORTED(1 << 2) is supported?Maybe if the bit n is set then functions 0..n are available? That would (almost) match what I see...
Quoted 7 lines
From the spec:
Supported DWORD Bit vector providing supported functions
information. Each bit marks
Functions Bit support for one specific function of the
ATIF method. Bit n, if set,
Vector indicates that Function n+1 is supported.Sorry, I still don't understand it... what's "Function n+1" in this context?
Does this mean that if bit n is set then the function defined as 1 << (n+1) is supported?Quoted 2 lines
I don't know how wonky bioses in the wild are however. I can see what our internal teams do in these sort of cases.
Quoted 8 lines
That would be helpful :)
Note that on this machine (Toshiba L855-10W) brightness control under windows does not work with the stock catalyst driver, it works only with the (oldish) driver supplied by Toshiba.Anyway, I'm attaching v2 of my patches, I've incorporated the suggestions and some bits of code from joeyli, and now brightness control is actually implemented.
Regarding patches 3 and 4, it might be easier to just store a pointer to the relevant encoder when you verify ATIF rather than walking the encoder list every time.
Alex
Quoted 5 lines
Still missing is the issue of event
0x81and the conflict with video.ko; the handler should probably returnNOTIFY_BADto veto the keypress.Luca
Quoted 3 lines · Alex Deucher
Regarding patches 3 and 4, it might be easier to just store a pointer to the relevant encoder when you verify ATIF rather than walking the encoder list every time.
Makes sense, I was unsure about the lifetime of the encoders, but AFAICS they're destroyed only when the module in unloaded.
Luca
Quoted 7 lines · Luca Tettamanti
Quoted 3 lines · Alex Deucher
Regarding patches 3 and 4, it might be easier to just store a pointer to the relevant encoder when you verify ATIF rather than walking the encoder list every time.
Makes sense, I was unsure about the lifetime of the encoders, but AFAICS they're destroyed only when the module in unloaded.
They are present for the life of the driver.
Alex
Quoted 5 lines · Alex Deucher
Quoted 4 lines · Luca Tettamanti
Quoted 3 lines · Alex Deucher
Regarding patches 3 and 4, it might be easier to just store a pointer to the relevant encoder when you verify ATIF rather than walking the encoder list every time.
Done.
Quoted 4 lines
Quoted 2 lines
Makes sense, I was unsure about the lifetime of the encoders, but AFAICS they're destroyed only when the module in unloaded.
They are present for the life of the driver.
I had to move to call to radeon_acpi_init after radeon_modeset_init, otherwise the encoders are not present yet (the tear down code path is correct, acpi first, then modeset).
Latest and greatest version is attached; I fixed notifications when using custom command codes (tested by Pali Rohár) and implemented your suggestion.
Luca
Quoted 1 line
From
f0f8699eabee0d47b93fba14f8126b821cc106a5Mon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Sun, 29 Jul 2012 17:04:43 +0200
Subject: [PATCH 1/4] drm/radeon: refactor radeon_atif_call
Don't hard-code function number, this will allow to reuse the function.
v2: add support for the 2nd parameter (from Lee, Chun-Yi <[email protected]>).
--- drivers/gpu/drm/radeon/radeon_acpi.c | 38 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-)
drivers/gpu/drm/radeon/radeon_acpi.c +23 -15
@@ -14,23 +14,30 @@#include <linux/vga_switcheroo.h> /* Call the ATIF method -* -* Note: currently we discard the output */ -static int radeon_atif_call (acpi_handle handle) +static union acpi_object *radeon_atif_call (acpi_handle handle,int function, +struct acpi_buffer *params) {acpi_status status;union acpi_object atif_arg_elements[2 ];struct acpi_object_list atif_arg; -struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; atif_arg.count =2 ; atif_arg.pointer = &atif_arg_elements[0 ]; atif_arg_elements[0 ].type =ACPI_TYPE_INTEGER ; - atif_arg_elements[0 ].integer.value =ATIF_FUNCTION_VERIFY_INTERFACE ; - atif_arg_elements[1 ].type =ACPI_TYPE_INTEGER ; - atif_arg_elements[1 ].integer.value =0 ; + atif_arg_elements[0 ].integer.value = function; + +if (params) { + atif_arg_elements[1 ].type =ACPI_TYPE_BUFFER ; + atif_arg_elements[1 ].buffer.length = params->length; + atif_arg_elements[1 ].buffer.pointer = params->pointer; + }else { +/* We need a second fake parameter */ + atif_arg_elements[1 ].type =ACPI_TYPE_INTEGER ; + atif_arg_elements[1 ].integer.value =0 ; + } status =acpi_evaluate_object (handle,"ATIF" , &atif_arg, &buffer);
@@ -39,18 +46,18 @@ static int radeon_atif_call(acpi_handle handle)DRM_DEBUG_DRIVER ("failed to evaluate ATIF got %s\n" ,acpi_format_exception (status));kfree (buffer.pointer); -return 1 ; +return NULL ; } -kfree (buffer.pointer); -return 0 ; +return buffer.pointer; }/* Call all ACPI methods here */ int radeon_acpi_init (struct radeon_device *rdev) {acpi_handle handle; -int ret; +union acpi_object *info; +int ret =0 ;/* Get the device handle */ handle =DEVICE_ACPI_HANDLE (&rdev->pdev->dev);
@@ -60,10 +67,11 @@ int radeon_acpi_init(struct radeon_device *rdev)return 0 ;/* Call the ATIF method */ - ret =radeon_atif_call (handle); -if (ret) -return ret; + info =radeon_atif_call (handle,ATIF_FUNCTION_VERIFY_INTERFACE ,NULL ); +if (!info) + ret = -EIO ; -return 0 ; +kfree (info); +return ret; }
Signature · 1 line
1.7.10.4
Quoted 1 line
From
427002ddf653b0abd0fb820b09322bf2a0b281afMon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Mon, 30 Jul 2012 21:11:58 +0200
Subject: [PATCH 2/4] drm/radeon: implement radeon_atif_verify_interface
Wrap the call to VERIFY_INTERFACE and add the parsing of the support vectors.
v2: use a packed struct for handling the output of ACPI calls, hides ugly pointer arithmetics (Lee, Chun-Yi <[email protected]>).
--- drivers/gpu/drm/radeon/radeon.h | 40 +++++++++++++++++ drivers/gpu/drm/radeon/radeon_acpi.c | 79 +++++++++++++++++++++++++++++++--- 2 files changed, 113 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon.h +40 -0
@@ -1456,6 +1456,44 @@ struct r600_vram_scratch {u64 gpu_addr; }; +/* +* ACPI +*/ +struct radeon_atif_notification_cfg { +bool enabled; +int command_code; +}; + +struct radeon_atif_notifications { +bool display_switch; +bool expansion_mode_change; +bool thermal_state; +bool forced_power_state; +bool system_power_state; +bool display_conf_change; +bool px_gfx_switch; +bool brightness_change; +bool dgpu_display_event; +}; + +struct radeon_atif_functions { +bool system_params; +bool sbios_requests; +bool select_active_disp; +bool lid_state; +bool get_tv_standard; +bool set_tv_standard; +bool get_panel_expansion_mode; +bool set_panel_expansion_mode; +bool temperature_change; +bool graphics_device_types; +}; + +struct radeon_atif { +struct radeon_atif_notifications notifications; +struct radeon_atif_functions functions; +struct radeon_atif_notification_cfg notification_cfg; +};/* * Core structure, functions and helpers.
@@ -1548,6 +1586,8 @@ struct radeon_device {unsigned debugfs_count;/* virtual memory */ struct radeon_vm_manager vm_manager; +/* ACPI interface */ +struct radeon_atif atif; }; int radeon_device_init(struct radeon_device *rdev,
drivers/gpu/drm/radeon/radeon_acpi.c +73 -6
102 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 1 line
From
e83d04d1b60c5cf46611f6afc9680024e1dad73bMon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Mon, 30 Jul 2012 21:16:06 +0200
Subject: [PATCH 3/4] drm/radeon: implement wrapper for GET_SYSTEM_PARAMS
Use GET_SYSTEM_PARAMS for retrieving the configuration for the system BIOS notifications.
v2: packed struct (Lee, Chun-Yi <[email protected]>)
--- drivers/gpu/drm/radeon/radeon_acpi.c | 84 +++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_acpi.c +82 -2
108 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 1 line
From
88a3e35a0495cfff7d1a8ea23b779c621b3e1faaMon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Mon, 30 Jul 2012 21:20:35 +0200
Subject: [PATCH 4/4] drm/radeon: implement handler for ACPI event
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Set up an handler for ACPI events and respond to brightness change requests from the system BIOS.
v2: fix notification when using device-specific command codes (tested by Pali Rohár <[email protected]>); cache the encoder controlling the backlight during the initialization to avoid searching it every time (suggested by Alex Deucher).
--- drivers/gpu/drm/radeon/atombios_encoders.c | 2 +- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_acpi.c | 132 +++++++++++++++++++++++++++- drivers/gpu/drm/radeon/radeon_acpi.h | 6 ++ drivers/gpu/drm/radeon/radeon_kms.c | 16 ++-- drivers/gpu/drm/radeon/radeon_mode.h | 2 + drivers/gpu/drm/radeon/radeon_pm.c | 4 +- 7 files changed, 152 insertions(+), 11 deletions(-)
drivers/gpu/drm/radeon/atombios_encoders.c +1 -1
@@ -72,7 +72,7 @@ radeon_atom_set_backlight_level_to_reg(struct radeon_device *rdev,WREG32 (RADEON_BIOS_2_SCRATCH , bios_2_scratch); } -static void +void atombios_set_panel_brightness (struct radeon_encoder *radeon_encoder) {struct drm_encoder *encoder = &radeon_encoder->base;
drivers/gpu/drm/radeon/radeon.h +1 -0
@@ -1493,6 +1493,7 @@ struct radeon_atif {struct radeon_atif_notifications notifications;struct radeon_atif_functions functions;struct radeon_atif_notification_cfg notification_cfg; +struct radeon_encoder *backlight_ctl; };/*
drivers/gpu/drm/radeon/radeon_acpi.c +128 -4
172 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_acpi.h +6 -0
@@ -24,6 +24,12 @@#ifndef RADEON_ACPI_H #define RADEON_ACPI_H +struct radeon_device ; +struct acpi_bus_event ; + +int radeon_atif_handler (struct radeon_device *rdev, +struct acpi_bus_event *event); +/* AMD hw uses four ACPI control methods: * 1. ATIF * ARG0: (ACPI_INTEGER) function code
drivers/gpu/drm/radeon/radeon_kms.c +11 -5
@@ -78,11 +78,6 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) goto out; } -/* Call ACPI methods */ - acpi_status =radeon_acpi_init (rdev); -if (acpi_status) -dev_dbg (&dev->pdev->dev,"Error during ACPI methods call\n" ); -/* Again modeset_init should fail only on fatal error * otherwise it should provide enough functionalities * for shadowfb to run
@@ -90,6 +85,17 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) r =radeon_modeset_init (rdev);if (r)dev_err (&dev->pdev->dev,"Fatal error during modeset init\n" ); + +/* Call ACPI methods: require modeset init +* but failure is not fatal +*/ +if (!r) { + acpi_status =radeon_acpi_init (rdev); +if (acpi_status) +dev_dbg (&dev->pdev->dev, +"Error during ACPI methods call\n" ); + } + out:if (r)radeon_driver_unload_kms (dev);
drivers/gpu/drm/radeon/radeon_mode.h +2 -0
@@ -697,6 +697,8 @@ void radeon_panel_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *adjusted_mode);void atom_rv515_force_tv_scaler (struct radeon_device *rdev,struct radeon_crtc *radeon_crtc); +void atombios_set_panel_brightness (struct radeon_encoder *radeon_encoder); +/* legacy tv */ void radeon_legacy_tv_adjust_crtc_reg(struct drm_encoder *encoder, uint32_t *h_total_disp, uint32_t *h_sync_strt_wid,
drivers/gpu/drm/radeon/radeon_pm.c +3 -1
@@ -22,6 +22,7 @@*/ #include "drmP.h" #include "radeon.h" +#include "radeon_acpi.h" #include "avivod.h" #include "atom.h" #ifdef CONFIG_ACPI
@@ -95,7 +96,8 @@ static int radeon_acpi_event(struct notifier_block *nb, } } -return NOTIFY_OK ; +/* Check for pending SBIOS requests */ +return radeon_atif_handler (rdev, entry); }#endif
Signature · 1 line
1.7.10.4
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 12 lines · Luca Tettamanti
Quoted 5 lines · Alex Deucher
Quoted 4 lines · Luca Tettamanti
Quoted 3 lines · Alex Deucher
Regarding patches 3 and 4, it might be easier to just store a pointer to the relevant encoder when you verify ATIF rather than walking the encoder list every time.
Done.
Quoted 3 lines
Quoted 2 lines
Makes sense, I was unsure about the lifetime of the encoders, but AFAICS they're destroyed only when the module in unloaded.
Quoted 8 lines
Quoted 1 line
They are present for the life of the driver.
I had to move to call to
radeon_acpi_initafterradeon_modeset_init, otherwise the encoders are not present yet (the tear down code path is correct, acpi first, then modeset).
Latest and greatest version is attached; I fixed notifications when using custom command codes (tested by Pali Rohár) and implemented your suggestion.
Patches look good. I picked them up and combined them with may patches plus a few other small fixes. They are available here:
http://cgit.freedesktop.org/~agd5f/linux/log/?h=acpi_patches
Let me know what you think.
Alex
Quoted 4 lines · Alex Deucher
Patches look good. I picked them up and combined them with may patches plus a few other small fixes. They are available here:
http://cgit.freedesktop.org/~agd5f/linux/log/?h=acpi_patches
Let me know what you think.
Looks ok, I lost one fix along the road though, I'm attaching the patch.
Luca
Quoted 1 line
From
0f71d5b56b9e5eee3194b5b926767511281ea0a6Mon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Wed, 1 Aug 2012 10:53:19 +0200
Subject: [PATCH] drm/radeon: fix, enable notifications with device specific
command code
--- drivers/gpu/drm/radeon/radeon_acpi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/radeon/radeon_acpi.c +1 -0
@@ -214,6 +214,7 @@ static int radeon_atif_get_notification_params(acpi_handle handle, err = -EINVAL ; goto out; } + n->enabled = true; n->command_code = params.command_code; }
Signature · 1 line
1.7.10.4
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Luca Tettamanti
Quoted 4 lines · Alex Deucher
Patches look good. I picked them up and combined them with may patches plus a few other small fixes. They are available here:
http://cgit.freedesktop.org/~agd5f/linux/log/?h=acpi_patches
Let me know what you think.Looks ok, I lost one fix along the road though, I'm attaching the patch.
Thanks, I rolled it into your original patch. New tree:
http://cgit.freedesktop.org/~agd5f/linux/log/?h=acpi_patches
Alex
Quoted 2 lines
Luca
I admit I'm not really an ACPI expert, but thinking about this more, I'm wondering if maybe we should just send the appropriate brightness change, switch display, etc. event to userspace rather than handling it directly in the radeon driver, then let userspace callback down via the bl interface, etc. With backlight for example, does handling it in the kernel driver as per your patch prevent userspace from seeing the brightness up/down event? Wouldn't that break things like OSD brightness displays and such?
Alex
Quoted 16 lines · Alex Deucher
Quoted 7 lines · Luca Tettamanti
Quoted 4 lines · Alex Deucher
Patches look good. I picked them up and combined them with may patches plus a few other small fixes. They are available here:
http://cgit.freedesktop.org/~agd5f/linux/log/?h=acpi_patches
Let me know what you think.Looks ok, I lost one fix along the road though, I'm attaching the patch.
Thanks, I rolled it into your original patch. New tree:
http://cgit.freedesktop.org/~agd5f/linux/log/?h=acpi_patchesAlex
Quoted 2 lines
Luca
Quoted 8 lines · Alex Deucher
I admit I'm not really an ACPI expert, but thinking about this more, I'm wondering if maybe we should just send the appropriate brightness change, switch display, etc. event to userspace rather than handling it directly in the radeon driver, then let userspace callback down via the bl interface, etc. With backlight for example, does handling it in the kernel driver as per your patch prevent userspace from seeing the brightness up/down event? Wouldn't that break things like OSD brightness displays and such?
No, the event is sent to userspace by the standard ACPI video driver, it works as before.
Changing brightness usually goes like this:
1) user presses a hotkey
2) a notification is generated (0x86 or 0x87)
3) video.ko handles the notification and calls into ACPI to change the level (_BCM) and firmware does its magic
4) a key press (brightness up/down) is sent to userspace
With ATIF step 3 does not actually change the brightness, it just send out another event (VIDEO_PROBE, or one of the device specific ones) so we need to take care of that too. The rest of the process, including the delivery of the key presses, stays the same.
Luca
Quoted 19 lines · Luca Tettamanti
Quoted 8 lines · Alex Deucher
I admit I'm not really an ACPI expert, but thinking about this more, I'm wondering if maybe we should just send the appropriate brightness change, switch display, etc. event to userspace rather than handling it directly in the radeon driver, then let userspace callback down via the bl interface, etc. With backlight for example, does handling it in the kernel driver as per your patch prevent userspace from seeing the brightness up/down event? Wouldn't that break things like OSD brightness displays and such?
No, the event is sent to userspace by the standard ACPI video driver, it works as before.
Changing brightness usually goes like this:
1) user presses a hotkey
2) a notification is generated (0x86or0x87)
3) video.ko handles the notification and calls into ACPI to change the level (_BCM) and firmware does its magic
4) a key press (brightness up/down) is sent to userspace
Quoted 4 lines
With ATIF step 3 does not actually change the brightness, it just send out another event (
VIDEO_PROBE, or one of the device specific ones) so we need to take care of that too. The rest of the process, including the delivery of the key presses, stays the same.
Excellent! thanks for clarifying.
Alex
Quoted 20 lines · Alex Deucher
Quoted 19 lines · Luca Tettamanti
Quoted 8 lines · Alex Deucher
I admit I'm not really an ACPI expert, but thinking about this more, I'm wondering if maybe we should just send the appropriate brightness change, switch display, etc. event to userspace rather than handling it directly in the radeon driver, then let userspace callback down via the bl interface, etc. With backlight for example, does handling it in the kernel driver as per your patch prevent userspace from seeing the brightness up/down event? Wouldn't that break things like OSD brightness displays and such?
No, the event is sent to userspace by the standard ACPI video driver, it works as before.
Changing brightness usually goes like this:
1) user presses a hotkey
2) a notification is generated (0x86or0x87)
3) video.ko handles the notification and calls into ACPI to change the level (_BCM) and firmware does its magic
4) a key press (brightness up/down) is sent to userspace
Quoted 4 lines
Quoted 4 lines
With ATIF step 3 does not actually change the brightness, it just send out another event (
VIDEO_PROBE, or one of the device specific ones) so we need to take care of that too. The rest of the process, including the delivery of the key presses, stays the same.
Updated tree with fixes to a few existing patches and improved support for ATPX and initial support for ATCS:
http://cgit.freedesktop.org/~agd5f/linux/?h=acpi_patches
Alex
[PATCH/RFC] drm/radeon: ACPI: veto the keypress on ATIF events
In reply to Alex DeucherAMD ACPI interface may overload the standard event ACPI_VIDEO_NOTIFY_PROBE (0x81) to signal AMD-specific events. In such cases we don't want to send the keypress (KEY_SWITCHVIDEOMODE) to the userspace because the user did not press the mode switch key (the spurious keypress confuses the DE which usually changes the display configuration and messes up a dual-screen setup). This patch gives the radeon driver the chance to examine the event and block the keypress if the event is an "AMD event".
---
Any comment from ACPI front?
drivers/acpi/video.c | 10 ++++++++-- drivers/gpu/drm/radeon/radeon_acpi.c | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/acpi/video.c +8 -2
@@ -1457,7 +1457,12 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)acpi_video_device_enumerate (video);acpi_video_device_rebind (video);acpi_bus_generate_proc_event (device, event,0 ); - keycode =KEY_SWITCHVIDEOMODE ; +/* This event is also overloaded by AMD ACPI interface, don't +* send the key press if the event has been handled elsewhere +* (e.g. radeon DRM driver). +*/ +if (!acpi_notifier_call_chain (device, event,0 )) + keycode =KEY_SWITCHVIDEOMODE ;break ;case ACPI_VIDEO_NOTIFY_CYCLE :/* Cycle Display output hotkey pressed. */
@@ -1479,7 +1484,8 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)break ; } -if (event !=ACPI_VIDEO_NOTIFY_SWITCH ) +if (event !=ACPI_VIDEO_NOTIFY_SWITCH && + event !=ACPI_VIDEO_NOTIFY_PROBE )acpi_notifier_call_chain (device, event,0 );if (keycode) {
drivers/gpu/drm/radeon/radeon_acpi.c +6 -1
@@ -273,7 +273,12 @@ int radeon_atif_handler(struct radeon_device *rdev, }/* TODO: check other events */ -return NOTIFY_OK ; +/* We've handled the event, stop the notifier chain. The ACPI interface +* overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to +* userspace if the event was generated only to signal a SBIOS +* request. +*/ +return NOTIFY_BAD ; }/* Call all ACPI methods here */
Signature · 1 line
1.7.10.4
Alex Deucher
Acked-byRe: [PATCH/RFC] drm/radeon: ACPI: veto the keypress on ATIF events
Quoted 10 lines · Luca Tettamanti
AMD ACPI interface may overload the standard event
ACPI_VIDEO_NOTIFY_PROBE(0x81) to signal AMD-specific events. In such cases we don't want to send the keypress (KEY_SWITCHVIDEOMODE) to the userspace because the user did not press the mode switch key (the spurious keypress confuses the DE which usually changes the display configuration and messes up a dual-screen setup). This patch gives the radeon driver the chance to examine the event and block the keypress if the event is an "AMD event".Signed-off-by Luca Tettamanti <[email protected]>
Looks good to me, but I'm certainly not an ACPI expert.
joeyli
Tested-byRe: [PATCH/RFC] drm/radeon: ACPI: veto the keypress on ATIF events
In reply to Luca Tettamanti於 三,2012-08-01 於 15:49 +0200,Luca Tettamanti 提到:
Quoted 10 lines
AMD ACPI interface may overload the standard event
ACPI_VIDEO_NOTIFY_PROBE(0x81) to signal AMD-specific events. In such cases we don't want to send the keypress (KEY_SWITCHVIDEOMODE) to the userspace because the user did not press the mode switch key (the spurious keypress confuses the DE which usually changes the display configuration and messes up a dual-screen setup). This patch gives the radeon driver the chance to examine the event and block the keypress if the event is an "AMD event".Signed-off-by Luca Tettamanti <[email protected]>
This patch works to me on my HP notebook to avoid (VGA, 0x81) notify event issued when AC-power unpluged.
Thanks
Joey Lee
Quoted 43 lines
---
Any comment from ACPI front?drivers/acpi/video.c | 10 ++++++++-- drivers/gpu/drm/radeon/radeon_acpi.c | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-)drivers/acpi/video.c +8
-2@@ -1457,7 +1457,12 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)acpi_video_device_enumerate (video);acpi_video_device_rebind (video);acpi_bus_generate_proc_event (device, event,0 ); - keycode =KEY_SWITCHVIDEOMODE ; +/* This event is also overloaded by AMD ACPI interface, don't +* send the key press if the event has been handled elsewhere +* (e.g. radeon DRM driver). +*/ +if (!acpi_notifier_call_chain (device, event,0 )) + keycode =KEY_SWITCHVIDEOMODE ;break ;case ACPI_VIDEO_NOTIFY_CYCLE :/* Cycle Display output hotkey pressed. */ @@ -1479,7 +1484,8 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)break ; } -if (event !=ACPI_VIDEO_NOTIFY_SWITCH ) +if (event !=ACPI_VIDEO_NOTIFY_SWITCH && + event !=ACPI_VIDEO_NOTIFY_PROBE )acpi_notifier_call_chain (device, event,0 );if (keycode) {drivers/gpu/drm/radeon/radeon_acpi.c +0
-0@@ -273,7 +273,12 @@ int radeon_atif_handler(struct radeon_device *rdev, }/* TODO: check other events */
drivers/gpu/drm/radeon/radeon_acpi.c int radeon_atif_handler(struct radeon_device *rdev, · line 284
Quoted 10 lines
drivers/gpu/drm/radeon/radeon_acpi.c +6
-1-return NOTIFY_OK ; +/* We've handled the event, stop the notifier chain. The ACPI interface +* overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to +* userspace if the event was generated only to signal a SBIOS +* request. +*/ +return NOTIFY_BAD ; }/* Call all ACPI methods here */
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH/RFC] drm/radeon: ACPI: veto the keypress on ATIF events
In reply to Luca TettamantiQuoted 9 lines · Luca Tettamanti
AMD ACPI interface may overload the standard event
ACPI_VIDEO_NOTIFY_PROBE(0x81) to signal AMD-specific events. In such cases we don't want to send the keypress (KEY_SWITCHVIDEOMODE) to the userspace because the user did not press the mode switch key (the spurious keypress confuses the DE which usually changes the display configuration and messes up a dual-screen setup). This patch gives the radeon driver the chance to examine the event and block the keypress if the event is an "AMD event".
Quoted 4 lines
Signed-off-by Luca Tettamanti <[email protected]>---
Any comment from ACPI front?
it looks good to me.
But I'm wondering if we can use the following code for ACPI part, which looks cleaner.
I know this may change the behavior of other events, but in theory, we should not send any input event if we know something wrong in kernel.
what do you think?
drivers/acpi/video.c +3 -4
@@ -1448,8 +1448,7 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)case ACPI_VIDEO_NOTIFY_SWITCH :/* User requested a switch, * most likely via hotkey. */ acpi_bus_generate_proc_event (device, event,0 ); -if (!acpi_notifier_call_chain (device, event,0 )) - keycode =KEY_SWITCHVIDEOMODE ; + keycode =KEY_SWITCHVIDEOMODE ;break ;case ACPI_VIDEO_NOTIFY_PROBE :/* User plugged in or removed a video
@@ -1479,8 +1478,8 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)break ; } -if (event !=ACPI_VIDEO_NOTIFY_SWITCH ) -acpi_notifier_call_chain (device, event,0 ); +if (acpi_notifier_call_chain (device, event,0 )) + keycode =0 ;if (keycode) {input_report_key (input, keycode,1 );
Quoted 40 lines
drivers/acpi/video.c | 10 ++++++++-- drivers/gpu/drm/radeon/radeon_acpi.c | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-)drivers/acpi/video.c +8
-2@@ -1457,7 +1457,12 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)acpi_video_device_enumerate (video);acpi_video_device_rebind (video);acpi_bus_generate_proc_event (device, event,0 ); - keycode =KEY_SWITCHVIDEOMODE ; +/* This event is also overloaded by AMD ACPI interface, don't +* send the key press if the event has been handled elsewhere +* (e.g. radeon DRM driver). +*/ +if (!acpi_notifier_call_chain (device, event,0 )) + keycode =KEY_SWITCHVIDEOMODE ;break ;case ACPI_VIDEO_NOTIFY_CYCLE :/* Cycle Display output hotkey pressed. */ @@ -1479,7 +1484,8 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)break ; } -if (event !=ACPI_VIDEO_NOTIFY_SWITCH ) +if (event !=ACPI_VIDEO_NOTIFY_SWITCH && + event !=ACPI_VIDEO_NOTIFY_PROBE )acpi_notifier_call_chain (device, event,0 );if (keycode) {drivers/gpu/drm/radeon/radeon_acpi.c +0
-0@@ -273,7 +273,12 @@ int radeon_atif_handler(struct radeon_device *rdev, }/* TODO: check other events */
drivers/gpu/drm/radeon/radeon_acpi.c int radeon_atif_handler(struct radeon_device *rdev, · line 284
Quoted 10 lines
drivers/gpu/drm/radeon/radeon_acpi.c +6
-1-return NOTIFY_OK ; +/* We've handled the event, stop the notifier chain. The ACPI interface +* overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to +* userspace if the event was generated only to signal a SBIOS +* request. +*/ +return NOTIFY_BAD ; }/* Call all ACPI methods here */
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH/RFC] drm/radeon: ACPI: veto the keypress on ATIF events
Quoted 14 lines · Zhang Rui
Quoted 9 lines · Luca Tettamanti
AMD ACPI interface may overload the standard event
ACPI_VIDEO_NOTIFY_PROBE(0x81) to signal AMD-specific events. In such cases we don't want to send the keypress (KEY_SWITCHVIDEOMODE) to the userspace because the user did not press the mode switch key (the spurious keypress confuses the DE which usually changes the display configuration and messes up a dual-screen setup). This patch gives the radeon driver the chance to examine the event and block the keypress if the event is an "AMD event".Quoted 4 lines
Signed-off-by Luca Tettamanti <[email protected]>---
Any comment from ACPI front?
Quoted 7 lines
it looks good to me.
But I'm wondering if we can use the following code for ACPI part, which looks cleaner.
I know this may change the behavior of other events, but in theory, we should not send any input event if we know something wrong in kernel.what do you think?
I like it, it's cleaner.
I've split the patch in two pieces (one for video, the other for radeon) and adopted your suggestion.
BTW, I'm leaving for vacation in a few hours, I'll be offline till mid August.
Luca
Quoted 1 line
From
acce30c96b90d1bc550e82a9e7f19226fa194d5eMon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Thu, 2 Aug 2012 15:30:27 +0200
Subject: [PATCH 1/2] ACPI video: allow events handlers to veto the keypress
The standard video events may be overloaded for device specific purposes. For example AMD ACPI interface overloads ACPI_VIDEO_NOTIFY_PROBE (0x81) to signal AMD-specific events. In such cases we don't want to send the keypress (KEY_SWITCHVIDEOMODE) to the userspace because the user did not press the mode switch key (the spurious keypress confuses the DE which usually changes the display configuration and messes up a dual-screen setup). This patch gives the handlers the chance to examine the event and block the keypress if the event is device specific.
v2: refactor as suggested by Zhang Rui <[email protected]>
--- drivers/acpi/video.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/video.c +4 -4
@@ -1448,8 +1448,7 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)case ACPI_VIDEO_NOTIFY_SWITCH :/* User requested a switch, * most likely via hotkey. */ acpi_bus_generate_proc_event (device, event,0 ); -if (!acpi_notifier_call_chain (device, event,0 )) - keycode =KEY_SWITCHVIDEOMODE ; + keycode =KEY_SWITCHVIDEOMODE ;break ;case ACPI_VIDEO_NOTIFY_PROBE :/* User plugged in or removed a video
@@ -1479,8 +1478,9 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)break ; } -if (event !=ACPI_VIDEO_NOTIFY_SWITCH ) -acpi_notifier_call_chain (device, event,0 ); +if (acpi_notifier_call_chain (device, event,0 )) +/* Something vetoed the keypress. */ + keycode =0 ;if (keycode) {input_report_key (input, keycode,1 );
Signature · 1 line
1.7.10.4
Quoted 1 line
From
def5119d8f617eef0fac2cd35d7bb18c176ff8f6Mon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Thu, 2 Aug 2012 15:33:03 +0200
Subject: [PATCH 2/2] drm/radeon: block the keypress on ATIF events
The AMD ACPI interface may use ACPI_VIDEO_NOTIFY_PROBE to signal SBIOS requests; block the keypress in this case since the user did not actually press the mode switch key.
--- drivers/gpu/drm/radeon/radeon_acpi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_acpi.c +6 -1
@@ -273,7 +273,12 @@ int radeon_atif_handler(struct radeon_device *rdev, }/* TODO: check other events */ -return NOTIFY_OK ; +/* We've handled the event, stop the notifier chain. The ACPI interface +* overloads ACPI_VIDEO_NOTIFY_PROBE, we don't want to send that to +* userspace if the event was generated only to signal a SBIOS +* request. +*/ +return NOTIFY_BAD ; }/* Call all ACPI methods here */
Signature · 1 line
1.7.10.4
Zhang Rui
Acked-byRe: [PATCH/RFC] drm/radeon: ACPI: veto the keypress on ATIF events
Quoted 21 lines · Luca Tettamanti
Quoted 20 lines · Zhang Rui
Quoted 9 lines · Luca Tettamanti
AMD ACPI interface may overload the standard event
ACPI_VIDEO_NOTIFY_PROBE(0x81) to signal AMD-specific events. In such cases we don't want to send the keypress (KEY_SWITCHVIDEOMODE) to the userspace because the user did not press the mode switch key (the spurious keypress confuses the DE which usually changes the display configuration and messes up a dual-screen setup). This patch gives the radeon driver the chance to examine the event and block the keypress if the event is an "AMD event".Quoted 4 lines
Signed-off-by Luca Tettamanti <[email protected]>---
Any comment from ACPI front?it looks good to me.
But I'm wondering if we can use the following code for ACPI part, which looks cleaner.
I know this may change the behavior of other events, but in theory, we should not send any input event if we know something wrong in kernel.
Quoted 6 lines
Quoted 1 line
what do you think?
I like it, it's cleaner.
I've split the patch in two pieces (one for video, the other for radeon) and adopted your suggestion.
Great.
hmm, who should take these two patches?
and which tree the second patch is based on?
thanks,
rui
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH/RFC] drm/radeon: ACPI: veto the keypress on ATIF events
Quoted 24 lines · Zhang Rui
Quoted 23 lines · Luca Tettamanti
Quoted 21 lines · Zhang Rui
Quoted 9 lines · Luca Tettamanti
AMD ACPI interface may overload the standard event
ACPI_VIDEO_NOTIFY_PROBE(0x81) to signal AMD-specific events. In such cases we don't want to send the keypress (KEY_SWITCHVIDEOMODE) to the userspace because the user did not press the mode switch key (the spurious keypress confuses the DE which usually changes the display configuration and messes up a dual-screen setup). This patch gives the radeon driver the chance to examine the event and block the keypress if the event is an "AMD event".Quoted 4 lines
Signed-off-by Luca Tettamanti <[email protected]>---
Any comment from ACPI front?it looks good to me.
But I'm wondering if we can use the following code for ACPI part, which looks cleaner.
I know this may change the behavior of other events, but in theory, we should not send any input event if we know something wrong in kernel.what do you think?
Quoted 8 lines
Quoted 4 lines
I like it, it's cleaner.
I've split the patch in two pieces (one for video, the other for radeon) and adopted your suggestion.Great.
Acked-by Zhang Rui <[email protected]>hmm, who should take these two patches?
I'm happy to take the patches.
Quoted 1 line
and which tree the second patch is based on?
I've got a tree with all the radeon ACPI patches on the acpi_patches branches of my git tree:git://people.freedesktop.org/~agd5f/linux
Alex
Quoted 4 lines
thanks,
rui
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH/RFC] drm/radeon: ACPI: veto the keypress on ATIF events
Quoted 34 lines · Alex Deucher
Quoted 24 lines · Zhang Rui
Quoted 23 lines · Luca Tettamanti
Quoted 21 lines · Zhang Rui
Quoted 9 lines · Luca Tettamanti
AMD ACPI interface may overload the standard event
ACPI_VIDEO_NOTIFY_PROBE(0x81) to signal AMD-specific events. In such cases we don't want to send the keypress (KEY_SWITCHVIDEOMODE) to the userspace because the user did not press the mode switch key (the spurious keypress confuses the DE which usually changes the display configuration and messes up a dual-screen setup). This patch gives the radeon driver the chance to examine the event and block the keypress if the event is an "AMD event".Quoted 4 lines
Signed-off-by Luca Tettamanti <[email protected]>---
Any comment from ACPI front?it looks good to me.
But I'm wondering if we can use the following code for ACPI part, which looks cleaner.
I know this may change the behavior of other events, but in theory, we should not send any input event if we know something wrong in kernel.what do you think?
Quoted 8 lines
Quoted 4 lines
I like it, it's cleaner.
I've split the patch in two pieces (one for video, the other for radeon) and adopted your suggestion.Great.
Acked-by Zhang Rui <[email protected]>hmm, who should take these two patches?
Quoted 8 lines
I'm happy to take the patches.
Quoted 1 line
and which tree the second patch is based on?
I've got a tree with all the radeon ACPI patches on the
acpi_patchesbranches of my git tree:git://people.freedesktop.org/~agd5f/linux
great.
thanks,
rui
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi,
I'm attaching a first draft of my work. The first 3 patches are infrastructure work, the fourth wires the notification handler and retrieves the requests from the system BIOS, but it does not actually change brightness yet.
The problem here is how to get the correct encoder: should I just scan encoder_list checking for ATOM_DEVICE_LCD_SUPPORT and see if it has a backlight device attached?
Hopefully there is only one encoder with it, right?
I'm also toying with the idea of creating structures matching the output of the various ACPI methods, this would remove some ugly pointer arithmetics, but it _might_ make it easier to read past the buffer if one does not check the size before using the struct. What do you think?
Luca
Quoted 1 line
From
e485a3a4075c25ba1747ad61f6168c3734d5f0a9Mon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Sun, 29 Jul 2012 17:04:43 +0200
Subject: [PATCH 1/4] drm/radeon: refactor radeon_atif_call
Don't hard-code function number, this will allow to reuse the function.
--- drivers/gpu/drm/radeon/radeon_acpi.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/gpu/drm/radeon/radeon_acpi.c +11 -12
@@ -14,10 +14,8 @@#include <linux/vga_switcheroo.h> /* Call the ATIF method -* -* Note: currently we discard the output */ -static int radeon_atif_call (acpi_handle handle) +static union acpi_object *radeon_atif_call (acpi_handle handle,int function) {acpi_status status;union acpi_object atif_arg_elements[2 ];
@@ -28,7 +26,7 @@ static int radeon_atif_call(acpi_handle handle) atif_arg.pointer = &atif_arg_elements[0 ]; atif_arg_elements[0 ].type =ACPI_TYPE_INTEGER ; - atif_arg_elements[0 ].integer.value =ATIF_FUNCTION_VERIFY_INTERFACE ; + atif_arg_elements[0 ].integer.value = function; atif_arg_elements[1 ].type =ACPI_TYPE_INTEGER ; atif_arg_elements[1 ].integer.value =0 ;
@@ -39,18 +37,18 @@ static int radeon_atif_call(acpi_handle handle)DRM_DEBUG_DRIVER ("failed to evaluate ATIF got %s\n" ,acpi_format_exception (status));kfree (buffer.pointer); -return 1 ; +return NULL ; } -kfree (buffer.pointer); -return 0 ; +return buffer.pointer; }/* Call all ACPI methods here */ int radeon_acpi_init (struct radeon_device *rdev) {acpi_handle handle; -int ret; +union acpi_object *info; +int ret =0 ;/* Get the device handle */ handle =DEVICE_ACPI_HANDLE (&rdev->pdev->dev);
@@ -60,10 +58,11 @@ int radeon_acpi_init(struct radeon_device *rdev)return 0 ;/* Call the ATIF method */ - ret =radeon_atif_call (handle); -if (ret) -return ret; + info =radeon_atif_call (handle,ATIF_FUNCTION_VERIFY_INTERFACE ); +if (!info) + ret = -EIO ; -return 0 ; +kfree (info); +return ret; }
Signature · 1 line
1.7.10.4
Quoted 1 line
From
b40c42f6808d84e36095f8b21daad28b39666628Mon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Sun, 29 Jul 2012 17:19:07 +0200
Subject: [PATCH 2/4] drm/radeon: implement radeon_atif_verify_interface
Wrap the call to VERIFY_INTERFACE and add the parsing of the support vectors.
--- drivers/gpu/drm/radeon/radeon.h | 40 ++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_acpi.c | 67 +++++++++++++++++++++++++++++++--- 2 files changed, 101 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon.h +40 -0
@@ -1456,6 +1456,44 @@ struct r600_vram_scratch {u64 gpu_addr; }; +/* +* ACPI +*/ +struct radeon_atif_notification_cfg { +bool enabled; +int command_code; +}; + +struct radeon_atif_notifications { +bool display_switch; +bool expansion_mode_change; +bool thermal_state; +bool forced_power_state; +bool system_power_state; +bool display_conf_change; +bool px_gfx_switch; +bool brightness_change; +bool dgpu_display_event; +}; + +struct radeon_atif_functions { +bool system_params; +bool sbios_requests; +bool select_active_disp; +bool lid_state; +bool get_tv_standard; +bool set_tv_standard; +bool get_panel_expansion_mode; +bool set_panel_expansion_mode; +bool temperature_change; +bool graphics_device_types; +}; + +struct radeon_atif { +struct radeon_atif_notifications notifications; +struct radeon_atif_functions functions; +struct radeon_atif_notification_cfg notification_cfg; +};/* * Core structure, functions and helpers.
@@ -1548,6 +1586,8 @@ struct radeon_device {unsigned debugfs_count;/* virtual memory */ struct radeon_vm_manager vm_manager; +/* ACPI interface */ +struct radeon_atif atif; }; int radeon_device_init(struct radeon_device *rdev,
drivers/gpu/drm/radeon/radeon_acpi.c +61 -6
84 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 1 line
From
9386cd89a085a83d2b3393e1e641c49d4e48cdddMon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Sun, 29 Jul 2012 17:30:54 +0200
Subject: [PATCH 3/4] drm/radeon: implement wrapper for GET_SYSTEM_PARAMS
Use GET_SYSTEM_PARAMS for retrieving the configuration for the system BIOS notifications.
--- drivers/gpu/drm/radeon/radeon_acpi.c | 77 +++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_acpi.c +75 -2
101 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 1 line
From
29937c81f1449d136c85145ceeeb7de24bfcc4c8Mon Sep 17 00:00:00 2001
From: Luca Tettamanti <[email protected]>
Date: Sun, 29 Jul 2012 21:00:51 +0200
Subject: [PATCH 4/4] drm/radeon: implement skeleton handler for ACPI events
--- drivers/gpu/drm/radeon/radeon_acpi.c | 72 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_acpi.h | 5 +++ drivers/gpu/drm/radeon/radeon_pm.c | 4 +- 3 files changed, 80 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_acpi.c +72 -0
84 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_acpi.h +5 -0
@@ -24,6 +24,11 @@#ifndef RADEON_ACPI_H #define RADEON_ACPI_H +struct radeon_device ; +struct acpi_bus_event ; + +int radeon_atif_handler (struct radeon_device *rdev,struct acpi_bus_event *event); +/* AMD hw uses four ACPI control methods: * 1. ATIF * ARG0: (ACPI_INTEGER) function code
drivers/gpu/drm/radeon/radeon_pm.c +3 -1
@@ -22,6 +22,7 @@*/ #include "drmP.h" #include "radeon.h" +#include "radeon_acpi.h" #include "avivod.h" #include "atom.h" #ifdef CONFIG_ACPI
@@ -95,7 +96,8 @@ static int radeon_acpi_event(struct notifier_block *nb, } } -return NOTIFY_OK ; +/* Check for pending SBIOS requests */ +return radeon_atif_handler (rdev, entry); }#endif
Signature · 1 line
1.7.10.4
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Luca Tettamanti
Hi,
I'm attaching a first draft of my work. The first 3 patches are infrastructure work, the fourth wires the notification handler and retrieves the requests from the system BIOS, but it does not actually change brightness yet.The problem here is how to get the correct encoder: should I just scan
encoder_listchecking forATOM_DEVICE_LCD_SUPPORTand see if it has a backlight device attached?
Yeah, that should work.
Quoted 1 line
Hopefully there is only one encoder with it, right?
There's only one backlight controller and there should only be one encoder with it enabled on it.
Quoted 5 lines
I'm also toying with the idea of creating structures matching the output of the various ACPI methods, this would remove some ugly pointer arithmetics, but it _might_ make it easier to read past the buffer if one does not check the size before using the struct. What do you think?
That's fine with me. We do something similar with atombios structs. Also, feel free to add stuff to radeon_acpi.h if you think it's useful.
Alex
Hi Luca,
於 六,2012-07-28 於 16:56 +0200,Luca Tettamanti 提到:
Quoted 36 lines · Alex Deucher
Quoted 19 lines · Luca Tettamanti
Quoted 18 lines · Alex Deucher
Quoted 7 lines · Luca Tettamanti
Quoted 2 lines
The other missing bit is how to actually change the brightness... Alex, do you know what registers to poke?
You need to check if the GPU controls the backlight or the system does. I think the attached patches should point you in the right direction.
Yep :)
0050:
ATOM_FIRMWARE_CAPABILITY_ACCESSusFirmwareCapability :
0050: (union)ATOM_FIRMWARE_CAPABILITYsbfAccess :USHORT GPUControlsBL:1 = 0x0001 (1)The panel is using the
INTERNAL_UNIPHYencoder, and I see the UNIPHYTransmitterControl command table.Quoted 6 lines
Quoted 4 lines
Interaction with video.ko is still a bit messy...
Do you already have code for handling the notifications? I'll work on it in the weekend otherwise ;)
I don't have patches for that. Please feel free to work on it :)
I just found the first problem (probably a BIOS bug):
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSis implemented in the DSDT, but the corresponding bitATIF_GET_SYSTEM_PARAMETERS_SUPPORTEDis not set :( I intended to use the method to set up the notification handler but now my BIOS says that it's not there even if it is...
Can I assume some default values (e.g. notifications are enabled and will use0x81unlessATIF_FUNCTION_GET_SYSTEM_PARAMETERSsays something different)?
Quoted 3 lines
thanks,
Luca
Did you check your DSDT for there have some "Notify (VGA, 0x81)" statement in AFN0..AFN15?
If YES, I think that means your machine in case the 0x81 is for ATI used by default.
On the other hand,
I am also trying to write patch for avoid my AC-power problem. Like your idea, I think just add radeon-acpi to acpi notifier chain then acpi/video feed event to chain before issue KEY code like Matthew's code for ACPI_VIDEO_NOTIFY_SWITCH with intel_opregion on 0x80. The following code for reference:
drivers/acpi/video.c +6 -2
@@ -91,6 +91,8 @@ static int acpi_video_bus_add(struct acpi_device *device);static int acpi_video_bus_remove (struct acpi_device *device,int type);static void acpi_video_bus_notify (struct acpi_device *device,u32 event); +static u16 video_notify_block_map; +static const struct acpi_device_id video_device_ids[] = { {ACPI_VIDEO_HID ,0 }, {"" ,0 },
@@ -1457,7 +1459,8 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)acpi_video_device_enumerate (video);acpi_video_device_rebind (video);acpi_bus_generate_proc_event (device, event,0 ); - keycode =KEY_SWITCHVIDEOMODE ; +if (!acpi_notifier_call_chain (device, event,0 )) + keycode =KEY_SWITCHVIDEOMODE ;break ;case ACPI_VIDEO_NOTIFY_CYCLE :/* Cycle Display output hotkey pressed. */
@@ -1479,7 +1482,8 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)break ; } -if (event !=ACPI_VIDEO_NOTIFY_SWITCH ) +if (event !=ACPI_VIDEO_NOTIFY_SWITCH || + event !=ACPI_VIDEO_NOTIFY_PROBE )acpi_notifier_call_chain (device, event,0 );if (keycode) {
Thanks a lot!
Joey Lee
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 13 lines · joeyli
Hi Luca,
於 六,2012-07-28 於 16:56 +0200,Luca Tettamanti 提到:
Quoted 9 lines
I just found the first problem (probably a BIOS bug):
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSis implemented in the DSDT, but the corresponding bitATIF_GET_SYSTEM_PARAMETERS_SUPPORTEDis not set :( I intended to use the method to set up the notification handler but now my BIOS says that it's not there even if it is...
Can I assume some default values (e.g. notifications are enabled and will use0x81unlessATIF_FUNCTION_GET_SYSTEM_PARAMETERSsays something different)?
Quoted 4 lines
Did you check your DSDT for there have some "Notify (VGA,
0x81)" statement in AFN0..AFN15?
If YES, I think that means your machine in case the0x81is for ATI used by default.
Yes, my point is that the nofication is there, but since GET_SYSTEM_PARAMETERS is not announced I have not way to check it. IOW, what is implemented in the DSDT does not match what is announced by VERIFY_INTERFACE.
For reference this is the DSDT: http://pastebin.com/KKS7ZsTt
Luca
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
於 日,2012-07-29 於 15:10 +0200,Luca Tettamanti 提到:
Quoted 19 lines · joeyli
Quoted 13 lines
Hi Luca,
於 六,2012-07-28 於 16:56 +0200,Luca Tettamanti 提到:
Quoted 9 lines
I just found the first problem (probably a BIOS bug):
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSis implemented in the DSDT, but the corresponding bitATIF_GET_SYSTEM_PARAMETERS_SUPPORTEDis not set :( I intended to use the method to set up the notification handler but now my BIOS says that it's not there even if it is...
Can I assume some default values (e.g. notifications are enabled and will use0x81unlessATIF_FUNCTION_GET_SYSTEM_PARAMETERSsays something different)?Quoted 4 lines
Did you check your DSDT for there have some "Notify (VGA,
0x81)" statement in AFN0..AFN15?
If YES, I think that means your machine in case the0x81is for ATI used by default.
Quoted 8 lines
Yes, my point is that the nofication is there, but since
GET_SYSTEM_PARAMETERSis not announced I have not way to check it. IOW, what is implemented in the DSDT does not match what is announced byVERIFY_INTERFACE.
For reference this is the DSDT: http://pastebin.com/KKS7ZsTtLuca
Yes, saw the problem in your DSDT:
Method (AF00, 0, NotSerialized)
{
CreateWordField (ATIB, Zero, SSZE)
...
Store (0x80, NMSK)
Store (0x02, SFUN) <=== 10b, bit 0 is 0
Return (ATIB)
}But, AF01 still supported in ATIF on this machine, maybe we should still try GET_SYSTEM_PARAMETERS even the function vector set to 0? No idea...
On the other hand,
My patch to avoid 0x81 event conflict with acpi/video driver like below. This patch woks on my notebook. Your patches do much more things then mine, so I think my patch just for reference.
There have a problem is:
If we want use acpi_notifier_call_chain to check does event consume by any notifier in acpi's blocking notifier chain, then we need return NOTIFY_BAD in radeon_acpi but not NOTIFY_OK.
So, I suggest radeon_acpi should register to acpi notifier chain by itself but not append on radeon_acpi_event in radeon_pm.
And,
suggest also check the device class is ACPI_VIDEO_CLASS like following:
+static int radeon_acpi_video_event(struct notifier_block *nb,
...
+ if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0)
+ return NOTIFY_DONE;
+
Thanks a lot!
Joey Lee
Quoted 1 line
From
9c0c42ab8f37dafd3b512ca395b64bf39819d26bMon Sep 17 00:00:00 2001
From: Lee, Chun-Yi <[email protected]>
Date: Mon, 30 Jul 2012 16:17:05 +0800
Subject: [PATCH] drm/radeon avoid 0x81 acpi event conflict with acpi video
driver
drm/radeon avoid 0x81 acpi event conflict with acpi video driver
--- drivers/acpi/video.c | 6 +- drivers/gpu/drm/radeon/radeon_acpi.c | 150 ++++++++++++++++++++++++++++++---- 2 files changed, 139 insertions(+), 17 deletions(-)
drivers/acpi/video.c +4 -2
@@ -1457,7 +1457,8 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)acpi_video_device_enumerate (video);acpi_video_device_rebind (video);acpi_bus_generate_proc_event (device, event,0 ); - keycode =KEY_SWITCHVIDEOMODE ; +if (!acpi_notifier_call_chain (device, event,0 )) + keycode =KEY_SWITCHVIDEOMODE ;break ;case ACPI_VIDEO_NOTIFY_CYCLE :/* Cycle Display output hotkey pressed. */
@@ -1479,7 +1480,8 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)break ; } -if (event !=ACPI_VIDEO_NOTIFY_SWITCH ) +if (event !=ACPI_VIDEO_NOTIFY_SWITCH || + event !=ACPI_VIDEO_NOTIFY_PROBE )acpi_notifier_call_chain (device, event,0 );if (keycode) {
drivers/gpu/drm/radeon/radeon_acpi.c +135 -15
188 lines not on this page · raw message
Signature · 8 lines
1.7.7 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 40 lines · joeyli
於 日,2012-07-29 於 15:10 +0200,Luca Tettamanti 提到:
Quoted 19 lines · joeyli
Quoted 13 lines
Hi Luca,
於 六,2012-07-28 於 16:56 +0200,Luca Tettamanti 提到:
Quoted 9 lines
I just found the first problem (probably a BIOS bug):
ATIF_FUNCTION_GET_SYSTEM_PARAMETERSis implemented in the DSDT, but the corresponding bitATIF_GET_SYSTEM_PARAMETERS_SUPPORTEDis not set :( I intended to use the method to set up the notification handler but now my BIOS says that it's not there even if it is...
Can I assume some default values (e.g. notifications are enabled and will use0x81unlessATIF_FUNCTION_GET_SYSTEM_PARAMETERSsays something different)?Quoted 4 lines
Did you check your DSDT for there have some "Notify (VGA,
0x81)" statement in AFN0..AFN15?
If YES, I think that means your machine in case the0x81is for ATI used by default.Quoted 8 lines
Yes, my point is that the nofication is there, but since
GET_SYSTEM_PARAMETERSis not announced I have not way to check it. IOW, what is implemented in the DSDT does not match what is announced byVERIFY_INTERFACE.
For reference this is the DSDT: http://pastebin.com/KKS7ZsTtLuca
Yes, saw the problem in your DSDT:
Method (AF00, 0, NotSerialized) { CreateWordField (ATIB, Zero, SSZE) ... Store (0x80, NMSK) Store (0x02, SFUN) <=== 10b, bit 0 is 0 Return (ATIB) }
Quoted 3 lines
But, AF01 still supported in ATIF on this machine, maybe we should still try
GET_SYSTEM_PARAMETERSeven the function vector set to 0? No idea...
That's what I'm doing right now... if SBIOS_REQUESTS is supported I try and call GET_SYSTEM_PARAMETERS even if it's not announced.
Quoted 4 lines
On the other hand,
My patch to avoid0x81event conflict with acpi/video driver like below. This patch woks on my notebook. Your patches do much more things then mine, so I think my patch just for reference.
I ignored the event handling for now... I'd like to hear something back from ACPI camp before committing to this solution.
Quoted 7 lines
There have a problem is:
If we want useacpi_notifier_call_chainto check does event consume by any notifier in acpi's blocking notifier chain, then we need returnNOTIFY_BADinradeon_acpibut notNOTIFY_OK.So, I suggest
radeon_acpishould register to acpi notifier chain by itself but not append onradeon_acpi_eventinradeon_pm.
It shouldn't matter, once I change radeon_atif_handler to return NOTIFY_BAD the call chain will be stopped anyway.
drivers/gpu/drm/radeon/radeon_acpi.c line 118
Quoted 8 lines
And,
suggest also check the device class isACPI_VIDEO_CLASSlike following:drivers/gpu/drm/radeon/radeon_acpi.c +4
-0+static int radeon_acpi_video_event(struct notifier_block *nb, + if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0) + return NOTIFY_DONE; +
Will do. I'll use the package structs in the next iteration.
Luca
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 11 lines · Alex Deucher <alexdeucher <at> gmail.com> writes:
Quoted 2 lines · Luca Tettamanti
The other missing bit is how to actually change the brightness... Alex, do you know what registers to poke?
You need to check if the GPU controls the backlight or the system does. I think the attached patches should point you in the right direction.
Alex
Hi, thank you very much for patches. With these patches now I'm able to adjust brightness on my notebook HP EliteBook 8460p with Radeon 6470M card via file /sys/class/backlight/radeon_bl/brightness
It has only one problem: When I enable Ambient Ligth Sensor via hp-wmi.ko driver (echo 1 > /sys/devices/platform/hp-wmi/als which auto adjust some brightness level based on sensor data on HW level) and I set radeon brightness to 0 or 255 (min or max value) screen is turned off. Values 1..254 are OK.
What about to disable values 0 and 255 in radeon brightness driver?
於 四,2012-07-26 於 14:58 +0200,Luca Tettamanti 提到:
Quoted 7 lines
- again ACPI video module gets the nodification (in this case
ACPI_VIDEO_NOTIFY_PROBE), re-enumerated and sendKEY_SWITCHVIDEOMODE
- KDE seems this and muck with the screen configuration :(
- meanwhile the brightness notification is propagated, the hypothetical
radeon driver does its magic to adjust the screen.
Quoted 5 lines
My first idea would be to make
ACPI_VIDEO_NOTIFY_PROBEalso call to the
acpi notifier chain, and allow the handlers to veto the key press (like
it's done forACPI_VIDEO_NOTIFY_SWITCH).
I welcome this approach!
On some ATI machine's DSDT also issue ACPI_VIDEO_NOTIFY_PROBE when AC-power unplug, because BIOS want to nodify video driver do some power saving stuff.
It causes KEY_SWITCHVIDEOMODE issued by acpi/video driver when AC-power unplug.
At least acpi/video driver need to know this 0x81 event is filed by BIOS to radeon-acpi for notify but not do video mode switch. That means the radeon drm need take the video switch responsibility.
Thanks a lot!
Joey Lee
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 22 lines · joeyli
於 四,2012-07-26 於 14:58 +0200,Luca Tettamanti 提到:
Quoted 7 lines
- again ACPI video module gets the nodification (in this case
ACPI_VIDEO_NOTIFY_PROBE), re-enumerated and sendKEY_SWITCHVIDEOMODE
- KDE seems this and muck with the screen configuration :(
- meanwhile the brightness notification is propagated, the hypothetical
radeon driver does its magic to adjust the screen.Quoted 5 lines
My first idea would be to make
ACPI_VIDEO_NOTIFY_PROBEalso call to the
acpi notifier chain, and allow the handlers to veto the key press (like
it's done forACPI_VIDEO_NOTIFY_SWITCH).I welcome this approach!
On some ATI machine's DSDT also issue
ACPI_VIDEO_NOTIFY_PROBEwhen AC-power unplug, because BIOS want to nodify video driver do some power saving stuff.
It causesKEY_SWITCHVIDEOMODEissued by acpi/video driver when AC-power unplug.
Quoted 3 lines
At least acpi/video driver need to know this
0x81event is filed by BIOS to radeon-acpi for notify but not do video mode switch. That means the radeon drm need take the video switch responsibility.
Probably we'd just want the radeon acpi handler to just forward the events to userspace so that the user can choose what to do with it (xrandr command, etc.), otherwise we'll need to define policy in the driver.
Alex
Quoted 5 lines
Thanks a lot!
Joey Lee
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
於 四,2012-07-26 於 23:31 -0400,Alex Deucher 提到:
Quoted 27 lines · joeyli
Quoted 22 lines
於 四,2012-07-26 於 14:58 +0200,Luca Tettamanti 提到:
Quoted 7 lines
- again ACPI video module gets the nodification (in this case
ACPI_VIDEO_NOTIFY_PROBE), re-enumerated and sendKEY_SWITCHVIDEOMODE
- KDE seems this and muck with the screen configuration :(
- meanwhile the brightness notification is propagated, the hypothetical
radeon driver does its magic to adjust the screen.Quoted 5 lines
My first idea would be to make
ACPI_VIDEO_NOTIFY_PROBEalso call to the
acpi notifier chain, and allow the handlers to veto the key press (like
it's done forACPI_VIDEO_NOTIFY_SWITCH).I welcome this approach!
On some ATI machine's DSDT also issue
ACPI_VIDEO_NOTIFY_PROBEwhen AC-power unplug, because BIOS want to nodify video driver do some power saving stuff.
It causesKEY_SWITCHVIDEOMODEissued by acpi/video driver when AC-power unplug.Quoted 3 lines
At least acpi/video driver need to know this
0x81event is filed by BIOS to radeon-acpi for notify but not do video mode switch. That means the radeon drm need take the video switch responsibility.
Quoted 7 lines
Probably we'd just want the radeon acpi handler to just forward the events to userspace so that the user can choose what to do with it (xrandr command, etc.), otherwise we'll need to define policy in the driver.
Alex
Any kernel module can issue KEY_SWITCHVIDEOMODE to user space, then gnome-settings-daemon(on Gnome) and krandr(on KDE) will call xrandr library to switch video mode.
The 0x81 ACPI event for acpi/video driver is ACPI_VIDEO_NOTIFY_PROBE, means need issue KEY_SWITCHVIDEOMODE. But, 0x81 for radeon is a general notification event.
I didn't see probe state in GET_SYSTEM_BIOS_REQUESTS, how can we distinguish this 0x81 is a ACPI_VIDEO_NOTIFY_PROBE or a ATI general notification event?
+ * flags
+ * bits 1:0:
+ * 0 - Notify(VGA, 0x81) is not used for notification
+ * 1 - Notify(VGA, 0x81) is used for notification
Per the above flags, when we detect bit set to 1, means 0x81 used for radeon-acpi to be a general notification event. My question is: what's the event number for ACPI_VIDEO_NOTIFY_PROBE on this AMD/ATI machine when 0x81 not available for acpi/video?
Thanks a lot!
Joey Lee
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 28 lines · joeyli
於 四,2012-07-26 於 23:31 -0400,Alex Deucher 提到:
Quoted 27 lines · joeyli
Quoted 25 lines
於 四,2012-07-26 於 14:58 +0200,Luca Tettamanti 提到:
Quoted 7 lines
- again ACPI video module gets the nodification (in this case
ACPI_VIDEO_NOTIFY_PROBE), re-enumerated and sendKEY_SWITCHVIDEOMODE
- KDE seems this and muck with the screen configuration :(
- meanwhile the brightness notification is propagated, the hypothetical
radeon driver does its magic to adjust the screen.Quoted 5 lines
My first idea would be to make
ACPI_VIDEO_NOTIFY_PROBEalso call to the
acpi notifier chain, and allow the handlers to veto the key press (like
it's done forACPI_VIDEO_NOTIFY_SWITCH).I welcome this approach!
On some ATI machine's DSDT also issue
ACPI_VIDEO_NOTIFY_PROBEwhen AC-power unplug, because BIOS want to nodify video driver do some power saving stuff.
It causesKEY_SWITCHVIDEOMODEissued by acpi/video driver when AC-power unplug.At least acpi/video driver need to know this
0x81event is filed by BIOS to radeon-acpi for notify but not do video mode switch. That means the radeon drm need take the video switch responsibility.
Quoted 8 lines
Quoted 4 lines
Probably we'd just want the radeon acpi handler to just forward the events to userspace so that the user can choose what to do with it (xrandr command, etc.), otherwise we'll need to define policy in the driver.
Any kernel module can issue
KEY_SWITCHVIDEOMODEto user space, then gnome-settings-daemon(on Gnome) and krandr(on KDE) will call xrandr library to switch video mode.
Exacly, and if we have pending system bios requests then the event is not a real ACPI_VIDEO_NOTIFY_PROBE and (IMHO) it should not be forwarded to the userspace as such.
The "vanilla" ACPI_VIDEO_NOTIFY_PROBE is already forwared to userspace.
Quoted 6 lines
The
0x81ACPI event for acpi/video driver isACPI_VIDEO_NOTIFY_PROBE, means need issueKEY_SWITCHVIDEOMODE. But,0x81for radeon is a general notification event.
I didn't see probe state inGET_SYSTEM_BIOS_REQUESTS, how can we distinguish this0x81is aACPI_VIDEO_NOTIFY_PROBEor a ATI general notification event?
+#define ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS 0x2
+/* ARG0: ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS
+ * ARG1: none
+ * OUTPUT:
+ * WORD - structure size in bytes (includes size field)
+ * DWORD - pending sbios requests
+ * BYTE - panel expansion mode + * BYTE - thermal state: target gfx controller + * BYTE - thermal state: state id (0: exit state, non-0: state) + * BYTE - forced power state: target gfx controller + * BYTE - forced power state: state id + * BYTE - system power source + * BYTE - panel backlight level (0-255)
I guess that if "pending sbios requests" == 0 then the event is the general purpose one, and is not handled by radeon driver.
Luca
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 48 lines · joeyli
於 四,2012-07-26 於 23:31 -0400,Alex Deucher 提到:
Quoted 27 lines · joeyli
Quoted 22 lines
於 四,2012-07-26 於 14:58 +0200,Luca Tettamanti 提到:
Quoted 7 lines
- again ACPI video module gets the nodification (in this case
ACPI_VIDEO_NOTIFY_PROBE), re-enumerated and sendKEY_SWITCHVIDEOMODE
- KDE seems this and muck with the screen configuration :(
- meanwhile the brightness notification is propagated, the hypothetical
radeon driver does its magic to adjust the screen.Quoted 5 lines
My first idea would be to make
ACPI_VIDEO_NOTIFY_PROBEalso call to the
acpi notifier chain, and allow the handlers to veto the key press (like
it's done forACPI_VIDEO_NOTIFY_SWITCH).I welcome this approach!
On some ATI machine's DSDT also issue
ACPI_VIDEO_NOTIFY_PROBEwhen AC-power unplug, because BIOS want to nodify video driver do some power saving stuff.
It causesKEY_SWITCHVIDEOMODEissued by acpi/video driver when AC-power unplug.Quoted 3 lines
At least acpi/video driver need to know this
0x81event is filed by BIOS to radeon-acpi for notify but not do video mode switch. That means the radeon drm need take the video switch responsibility.Quoted 7 lines
Probably we'd just want the radeon acpi handler to just forward the events to userspace so that the user can choose what to do with it (xrandr command, etc.), otherwise we'll need to define policy in the driver.
Alex
Any kernel module can issue
KEY_SWITCHVIDEOMODEto user space, then gnome-settings-daemon(on Gnome) and krandr(on KDE) will call xrandr library to switch video mode.The
0x81ACPI event for acpi/video driver isACPI_VIDEO_NOTIFY_PROBE, means need issueKEY_SWITCHVIDEOMODE. But,0x81for radeon is a general notification event.
I didn't see probe state inGET_SYSTEM_BIOS_REQUESTS, how can we distinguish this0x81is aACPI_VIDEO_NOTIFY_PROBEor a ATI general notification event?
Quoted 9 lines
+ * flags
+ * bits 1:0:
+ * 0 -Notify(VGA, 0x81)is not used for notification
+ * 1 -Notify(VGA, 0x81)is used for notificationPer the above flags, when we detect bit set to 1, means
0x81used for radeon-acpi to be a general notification event. My question is: what's the event number forACPI_VIDEO_NOTIFY_PROBEon this AMD/ATI machine when0x81not available for acpi/video?
+/* ARG0: ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
+ * ARG1: none
+ * OUTPUT:
+ * WORD - structure size in bytes (includes size field)
+ * DWORD - valid flags mask
+ * DWORD - flags
+ *
+ * OR
+ *
+ * WORD - structure size in bytes (includes size field)
+ * DWORD - valid flags mask
+ * DWORD - flags
+ * BYTE - notify command code
+ *
+ * flags
+ * bits 1:0:
+ * 0 - Notify(VGA, 0x81) is not used for notification
+ * 1 - Notify(VGA, 0x81) is used for notification
+ * 2 - Notify(VGA, n) is used for notification where
+ * n (0xd0-0xd9) is specified in notify command code.
+ * bit 2:
+ * 1 - lid changes not reported though int10
+ */
if bits 1:0 == 0, there is no notify event for radeon. When bits 1:0 == 1, it uses 0x81; when bits 1:0 == 2 it uses the event number specified in the following byte (notify command code) which would be something in the 0xd0-0xd9 range.
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
於 五,2012-07-27 於 09:21 -0400,Alex Deucher 提到:
Quoted 37 lines · joeyli
Quoted 10 lines
+ * flags
+ * bits 1:0:
+ * 0 -Notify(VGA, 0x81)is not used for notification
+ * 1 -Notify(VGA, 0x81)is used for notificationPer the above flags, when we detect bit set to 1, means
0x81used for radeon-acpi to be a general notification event. My question is: what's the event number forACPI_VIDEO_NOTIFY_PROBEon this AMD/ATI machine when0x81not available for acpi/video?+/* ARG0:
ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
+ * ARG1: none
+ * OUTPUT:
+ * WORD - structure size in bytes (includes size field)
+ * DWORD - valid flags mask
+ * DWORD - flags
+ *
+ * OR
+ *
+ * WORD - structure size in bytes (includes size field)
+ * DWORD - valid flags mask
+ * DWORD - flags
+ * BYTE - notify command code
+ *
+ * flags
+ * bits 1:0:
+ * 0 -Notify(VGA, 0x81)is not used for notification
+ * 1 -Notify(VGA, 0x81)is used for notification
+ * 2 -Notify(VGA, n)is used for notification where
+ * n (0xd0-0xd9) is specified in notify command code.
+ * bit 2:
+ * 1 - lid changes not reported though int10
+ */
Quoted 6 lines
if bits 1:0 == 0, there is no notify event for radeon. When bits 1:0 == 1, it uses
0x81; when bits 1:0 == 2 it uses the event number specified in the following byte (notify command code) which would be something in the 0xd0-0xd9 range.Alex
Did you mean every time we received 0x81 event in kernel module, we need access GET_SYSTEM_PARAMETERS to get the flags for distinguish between ACPI_VIDEO_NOTIFY_PROBE?
Or just need access ONE time when system boot?
I have a machine the GET_SYSTEM_PARAMETERS looks like this:
Method (AF01, 0, NotSerialized) /* ATIF_FUNCTION_GET_SYSTEM_PARAMETERS 0x1 */
{
CreateWordField (ATIB, Zero, SSZE)
CreateDWordField (ATIB, 0x02, VMSK)
CreateDWordField (ATIB, 0x06, FLGS) /* flags bits 1:0 */
Store (0x0A, SSZE) /* structure SIZE fixed */
Store (0x03, VMSK) /* valid flags mask fixed to 0x03 */
Store (One, FLGS) /* FLAGS always set to 1 */
Return (ATIB)
}Looks like just need access ONE time when system boot because those return value of AF01 fixed in DSDT.
On this machine doesn't support probe event, I didn't see any event issued when I plug D-Sub. Does that means those kind of ATI/AMD machines do NOT support probe notify?
If YES, then we can just direct disable acpi/video driver by radeon-acpi when we detected FLAGS is 1.
Thanks a lot!
Joey Lee
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
於 五,2012-07-27 於 23:32 +0800,joeyli 提到:
Quoted 65 lines
於 五,2012-07-27 於 09:21 -0400,Alex Deucher 提到:
Quoted 37 lines · joeyli
Quoted 10 lines
+ * flags
+ * bits 1:0:
+ * 0 -Notify(VGA, 0x81)is not used for notification
+ * 1 -Notify(VGA, 0x81)is used for notificationPer the above flags, when we detect bit set to 1, means
0x81used for radeon-acpi to be a general notification event. My question is: what's the event number forACPI_VIDEO_NOTIFY_PROBEon this AMD/ATI machine when0x81not available for acpi/video?+/* ARG0:
ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
+ * ARG1: none
+ * OUTPUT:
+ * WORD - structure size in bytes (includes size field)
+ * DWORD - valid flags mask
+ * DWORD - flags
+ *
+ * OR
+ *
+ * WORD - structure size in bytes (includes size field)
+ * DWORD - valid flags mask
+ * DWORD - flags
+ * BYTE - notify command code
+ *
+ * flags
+ * bits 1:0:
+ * 0 -Notify(VGA, 0x81)is not used for notification
+ * 1 -Notify(VGA, 0x81)is used for notification
+ * 2 -Notify(VGA, n)is used for notification where
+ * n (0xd0-0xd9) is specified in notify command code.
+ * bit 2:
+ * 1 - lid changes not reported though int10
+ */Quoted 6 lines
if bits 1:0 == 0, there is no notify event for radeon. When bits 1:0 == 1, it uses
0x81; when bits 1:0 == 2 it uses the event number specified in the following byte (notify command code) which would be something in the 0xd0-0xd9 range.Alex
Did you mean every time we received
0x81event in kernel module, we need accessGET_SYSTEM_PARAMETERSto get the flags for distinguish betweenACPI_VIDEO_NOTIFY_PROBE?Or just need access ONE time when system boot?
I have a machine the
GET_SYSTEM_PARAMETERSlooks like this:Method (AF01, 0, NotSerialized) /*
ATIF_FUNCTION_GET_SYSTEM_PARAMETERS0x1*/{ CreateWordField (ATIB, Zero, SSZE) CreateDWordField (ATIB, 0x02, VMSK) CreateDWordField (ATIB, 0x06, FLGS) /* flags bits 1:0 */ Store (0x0A, SSZE) /* structure SIZE fixed */ Store (0x03, VMSK) /* valid flags mask fixed to 0x03 */ Store (One, FLGS) /* FLAGS always set to 1 */ Return (ATIB) }
Quoted 8 lines
Looks like just need access ONE time when system boot because those return value of AF01 fixed in DSDT.
On this machine doesn't support probe event, I didn't see any event issued when I plug D-Sub. Does that means those kind of ATI/AMD machines do NOT support probe notify?
If YES, then we can just direct disable acpi/video driver by radeon-acpi
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 2 lines
when we detected FLAGS is 1.
I mean disable the ACPI_VIDEO_NOTIFY_PROBE related code in acpi/video driver.
Thanks
Joey Lee
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 43 lines · joeyli
於 五,2012-07-27 於 09:21 -0400,Alex Deucher 提到:
Quoted 42 lines · joeyli
Quoted 10 lines
+ * flags
+ * bits 1:0:
+ * 0 -Notify(VGA, 0x81)is not used for notification
+ * 1 -Notify(VGA, 0x81)is used for notificationPer the above flags, when we detect bit set to 1, means
0x81used for radeon-acpi to be a general notification event. My question is: what's the event number forACPI_VIDEO_NOTIFY_PROBEon this AMD/ATI machine when0x81not available for acpi/video?+/* ARG0:
ATIF_FUNCTION_GET_SYSTEM_PARAMETERS
+ * ARG1: none
+ * OUTPUT:
+ * WORD - structure size in bytes (includes size field)
+ * DWORD - valid flags mask
+ * DWORD - flags
+ *
+ * OR
+ *
+ * WORD - structure size in bytes (includes size field)
+ * DWORD - valid flags mask
+ * DWORD - flags
+ * BYTE - notify command code
+ *
+ * flags
+ * bits 1:0:
+ * 0 -Notify(VGA, 0x81)is not used for notification
+ * 1 -Notify(VGA, 0x81)is used for notification
+ * 2 -Notify(VGA, n)is used for notification where
+ * n (0xd0-0xd9) is specified in notify command code.
+ * bit 2:
+ * 1 - lid changes not reported though int10
+ */if bits 1:0 == 0, there is no notify event for radeon. When bits 1:0 == 1, it uses
0x81; when bits 1:0 == 2 it uses the event number specified in the following byte (notify command code) which would be something in the 0xd0-0xd9 range.
Quoted 7 lines
Quoted 1 line
Alex
Did you mean every time we received
0x81event in kernel module, we need accessGET_SYSTEM_PARAMETERSto get the flags for distinguish betweenACPI_VIDEO_NOTIFY_PROBE?Or just need access ONE time when system boot?
Just once at start up to see what event, if any, the sbios will use to signal the driver.
Quoted 15 lines
I have a machine the
GET_SYSTEM_PARAMETERSlooks like this:Method (AF01, 0, NotSerialized) /*
ATIF_FUNCTION_GET_SYSTEM_PARAMETERS0x1*/{ CreateWordField (ATIB, Zero, SSZE) CreateDWordField (ATIB, 0x02, VMSK) CreateDWordField (ATIB, 0x06, FLGS) /* flags bits 1:0 */ Store (0x0A, SSZE) /* structure SIZE fixed */ Store (0x03, VMSK) /* valid flags mask fixed to 0x03 */ Store (One, FLGS) /* FLAGS always set to 1 */ Return (ATIB) }
Quoted 6 lines
Looks like just need access ONE time when system boot because those return value of AF01 fixed in DSDT.
On this machine doesn't support probe event, I didn't see any event issued when I plug D-Sub. Does that means those kind of ATI/AMD machines do NOT support probe notify?
Analog connectors don't support hotplug at all. And hotplug on digital connectors is already handled by the driver. As far as I know ACPI doesn't provide any events for these. The driver gets interrupts directly from the hw. The only events the sbios uses the notify event for are the ones listed in the supported notifications mask from ATIF_FUNCTION_VERIFY_INTERFACE:
+#define ATIF_FUNCTION_VERIFY_INTERFACE 0x0
+/* ARG0: ATIF_FUNCTION_VERIFY_INTERFACE
+ * ARG1: none
+ * OUTPUT:
+ * WORD - structure size in bytes (includes size field)
+ * WORD - version
+ * DWORD - supported notifications mask
+ * DWORD - supported functions bit vector
+ */
+/* Notifications mask */
+# define ATIF_DISPLAY_SWITCH_REQUEST_SUPPORTED (1 << 0) +# define ATIF_EXPANSION_MODE_CHANGE_REQUEST_SUPPORTED (1 << 1) +# define ATIF_THERMAL_STATE_CHANGE_REQUEST_SUPPORTED (1 << 2) +# define ATIF_FORCED_POWER_STATE_CHANGE_REQUEST_SUPPORTED (1 << 3) +# define ATIF_SYSTEM_POWER_SOURCE_CHANGE_REQUEST_SUPPORTED (1 << 4) +# define ATIF_DISPLAY_CONF_CHANGE_REQUEST_SUPPORTED (1 << 5) +# define ATIF_PX_GFX_SWITCH_REQUEST_SUPPORTED (1 << 6) +# define ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST_SUPPORTED (1 << 7) +# define ATIF_DGPU_DISPLAY_EVENT_SUPPORTED (1 << 8)
They are things like the user presses the display switch hotkey or presses the brightness up hotkey.
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html