FreeBSD/sys/dev/drm2/radeon/radeon_acpi.c
/**
 * 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.
 */
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.
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 .
static int radeon_atif_get_notification_params(ACPI_HANDLE handle,
		struct radeon_atif_notification_cfg *n)
{
	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;
	}
	size = *(u16 *) info->Buffer.Pointer;
	if (size < 10) {
		err = -EINVAL;
		goto out;
	}
	memset(&params, 0, sizeof(params));
	size = min(sizeof(params), size);
	memcpy(&params, info->Buffer.Pointer, size);
	DRM_DEBUG_DRIVER("SYSTEM_PARAMS: mask = %#x, flags = %#x\n",
			params.flags, params.valid_mask);
	params.flags = params.flags & params.valid_mask;
	if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_NONE) {
		n->enabled = false;
		n->command_code = 0;
	} else if ((params.flags & ATIF_NOTIFY_MASK) == ATIF_NOTIFY_81) {
		n->enabled = true;
		n->command_code = 0x81;
	} else {
		if (size < 11) {
			err = -EINVAL;
			goto out;
		}
		n->enabled = true;
		n->command_code = params.command_code;
	}
out:
	DRM_DEBUG_DRIVER("Notification %s, command code = %#x\n",
			(n->enabled ? "enabled" : "disabled"),
			n->command_code);
	AcpiOsFree(info);
	return err;
}
static int radeon_atif_get_notification_params ( ACPI_HANDLE handle , struct radeon_atif_notification_cfg * n ) { 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 ; } size = * ( u16 * ) info -> Buffer . Pointer ; if ( size < 10 ) { err = - EINVAL ; goto out ; } memset ( & params , 0 , sizeof ( params ) ) ; size = min ( sizeof ( params ) , size ) ; memcpy ( & params , info -> Buffer . Pointer , size ) ; DRM_DEBUG_DRIVER ( " \n " , params . flags , params . valid_mask ) ; params . flags = params . flags & params . valid_mask ; if ( ( params . flags & ATIF_NOTIFY_MASK ) == ATIF_NOTIFY_NONE ) { n -> enabled = false ; n -> command_code = 0 ; } else if ( ( params . flags & ATIF_NOTIFY_MASK ) == ATIF_NOTIFY_81 ) { n -> enabled = true ; n -> command_code = 0x81 ; } else { if ( size < 11 ) { err = - EINVAL ; goto out ; } n -> enabled = true ; n -> command_code = params . command_code ; } out : DRM_DEBUG_DRIVER ( " \n " , ( n -> enabled ? " " : " " ) , n -> command_code ) ; AcpiOsFree ( info ) ; return err ; }
radeon_atif_get_notification_params - determine notify configuration
 @handle: acpi handle
 @n: atif notification configuration struct
radeon_atif_get_notification_params - determine notify configuration @handle : acpi handle @n : atif notification configuration struct