/* * Copyright 2012 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. *
*/
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);
/* Fail only if calling the method fails and ATIF is supported */ if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
acpi_format_exception(status));
kfree(buffer.pointer); return NULL;
}
/** * radeon_atif_get_notification_params - determine notify configuration * * @handle: acpi handle * @n: atif notification configuration struct * * Execute the ATIF_FUNCTION_GET_SYSTEM_PARAMETERS ATIF function * to determine if a notifier is used and if so which one * (all asics). This is either Notify(VGA, 0x81) or Notify(VGA, n) * where n is specified in the result if a notifier is used. * Returns 0 on success, error on failure.
*/ staticint radeon_atif_get_notification_params(acpi_handle handle, struct radeon_atif_notification_cfg *n)
{ union acpi_object *info; struct atif_system_params params;
size_t size; int err = 0;
info = radeon_atif_call(handle, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS, NULL); if (!info) {
err = -EIO; goto out;
}
/** * radeon_atif_get_sbios_requests - get requested sbios event * * @handle: acpi handle * @req: atif sbios request struct * * Execute the ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS ATIF function * to determine what requests the sbios is making to the driver * (all asics). * Returns 0 on success, error on failure.
*/ staticint radeon_atif_get_sbios_requests(acpi_handle handle, struct atif_sbios_requests *req)
{ union acpi_object *info;
size_t size; int count = 0;
info = radeon_atif_call(handle, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS, NULL); if (!info) return -EIO;
if (rdev->is_atom_bios) { struct radeon_encoder_atom_dig *dig = enc->enc_priv;
backlight_force_update(dig->bl_dev,
BACKLIGHT_UPDATE_HOTKEY);
} else { struct radeon_encoder_lvds *dig = enc->enc_priv;
backlight_force_update(dig->bl_dev,
BACKLIGHT_UPDATE_HOTKEY);
}
}
} if (req.pending & ATIF_DGPU_DISPLAY_EVENT) { if ((rdev->flags & RADEON_IS_PX) &&
radeon_atpx_dgpu_req_power_for_displays()) {
pm_runtime_get_sync(rdev_to_drm(rdev)->dev); /* Just fire off a uevent and let userspace tell us what to do */
drm_helper_hpd_irq_event(rdev_to_drm(rdev));
pm_runtime_mark_last_busy(rdev_to_drm(rdev)->dev);
pm_runtime_put_autosuspend(rdev_to_drm(rdev)->dev);
}
} /* TODO: check other events */
/* 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 the ATCS method
*/ /** * radeon_atcs_call - call an ATCS method * * @handle: acpi handle * @function: the ATCS function to execute * @params: ATCS function params * * Executes the requested ATCS function (all asics). * Returns a pointer to the acpi output buffer.
*/ staticunion acpi_object *radeon_atcs_call(acpi_handle handle, int function, struct acpi_buffer *params)
{
acpi_status status; union acpi_object atcs_arg_elements[2]; struct acpi_object_list atcs_arg; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
if (params) {
atcs_arg_elements[1].type = ACPI_TYPE_BUFFER;
atcs_arg_elements[1].buffer.length = params->length;
atcs_arg_elements[1].buffer.pointer = params->pointer;
} else { /* We need a second fake parameter */
atcs_arg_elements[1].type = ACPI_TYPE_INTEGER;
atcs_arg_elements[1].integer.value = 0;
}
status = acpi_evaluate_object(handle, "ATCS", &atcs_arg, &buffer);
/* Fail only if calling the method fails and ATIF is supported */ if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
DRM_DEBUG_DRIVER("failed to evaluate ATCS got %s\n",
acpi_format_exception(status));
kfree(buffer.pointer); return NULL;
}
return buffer.pointer;
}
/** * radeon_atcs_parse_functions - parse supported functions * * @f: supported functions struct * @mask: supported functions mask from ATCS * * Use the supported functions mask from ATCS function * ATCS_FUNCTION_VERIFY_INTERFACE to determine what functions * are supported (all asics).
*/ staticvoid radeon_atcs_parse_functions(struct radeon_atcs_functions *f, u32 mask)
{
f->get_ext_state = mask & ATCS_GET_EXTERNAL_STATE_SUPPORTED;
f->pcie_perf_req = mask & ATCS_PCIE_PERFORMANCE_REQUEST_SUPPORTED;
f->pcie_dev_rdy = mask & ATCS_PCIE_DEVICE_READY_NOTIFICATION_SUPPORTED;
f->pcie_bus_width = mask & ATCS_SET_PCIE_BUS_WIDTH_SUPPORTED;
}
/** * radeon_atcs_verify_interface - verify ATCS * * @handle: acpi handle * @atcs: radeon atcs struct * * Execute the ATCS_FUNCTION_VERIFY_INTERFACE ATCS function * to initialize ATCS and determine what features are supported * (all asics). * returns 0 on success, error on failure.
*/ staticint radeon_atcs_verify_interface(acpi_handle handle, struct radeon_atcs *atcs)
{ union acpi_object *info; struct atcs_verify_interface output;
size_t size; int err = 0;
info = radeon_atcs_call(handle, ATCS_FUNCTION_VERIFY_INTERFACE, NULL); if (!info) return -EIO;
memset(&output, 0, sizeof(output));
size = *(u16 *) info->buffer.pointer; if (size < 8) {
DRM_INFO("ATCS buffer is too small: %zu\n", size);
err = -EINVAL; goto out;
}
size = min(sizeof(output), size);
memcpy(&output, info->buffer.pointer, size);
/* TODO: check version? */
DRM_DEBUG_DRIVER("ATCS version %u\n", output.version);
if (atif->functions.sbios_requests && !atif->functions.system_params) { /* XXX check this workraround, if sbios request function is * present we have to see how it's configured in the system * params
*/
atif->functions.system_params = true;
}
if (atif->functions.system_params) {
ret = radeon_atif_get_notification_params(handle,
&atif->notification_cfg); if (ret) {
DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
ret); /* Disable notification */
atif->notification_cfg.enabled = false;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.