/* * Functions bit vector for WBRF method * * Bit 0: WBRF supported. * Bit 1: Function 1 (Add / Remove frequency) is supported. * Bit 2: Function 2 (Get frequency list) is supported.
*/ #define WBRF_ENABLED 0x0 #define WBRF_RECORD 0x1 #define WBRF_RETRIEVE 0x2
#define WBRF_REVISION 0x1
/* * The data structure used for WBRF_RETRIEVE is not naturally aligned. * And unfortunately the design has been settled down.
*/ struct amd_wbrf_ranges_out {
u32 num_of_ranges; struct freq_band_range band_list[MAX_NUM_OF_WBRF_RANGES];
} __packed;
/* * Used to notify consumer (amdgpu driver currently) about * the wifi frequency is change.
*/ static BLOCKING_NOTIFIER_HEAD(wbrf_chain_head);
staticint wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ranges_in_out *in)
{ union acpi_object argv4; union acpi_object *tmp; union acpi_object *obj;
u32 num_of_ranges = 0;
u32 num_of_elements;
u32 arg_idx = 0; int ret;
u32 i;
if (!in) return -EINVAL;
for (i = 0; i < ARRAY_SIZE(in->band_list); i++) { if (in->band_list[i].start && in->band_list[i].end)
num_of_ranges++;
}
/* * The num_of_ranges value in the "in" object supplied by * the caller is required to be equal to the number of * entries in the band_list array in there.
*/ if (num_of_ranges != in->num_of_ranges) return -EINVAL;
/* * Every input frequency band comes with two end points(start/end) * and each is accounted as an element. Meanwhile the range count * and action type are accounted as an element each. * So, the total element count = 2 * num_of_ranges + 1 + 1.
*/
num_of_elements = 2 * num_of_ranges + 2;
tmp = kcalloc(num_of_elements, sizeof(*tmp), GFP_KERNEL); if (!tmp) return -ENOMEM;
if (obj->type != ACPI_TYPE_INTEGER) {
ret = -EINVAL; goto out;
}
ret = obj->integer.value; if (ret)
ret = -EINVAL;
out:
ACPI_FREE(obj);
kfree(tmp);
return ret;
}
/** * acpi_amd_wbrf_add_remove - add or remove the frequency band the device is using * * @dev: device pointer * @action: remove or add the frequency band into bios * @in: input structure containing the frequency band the device is using * * Broadcast to other consumers the frequency band the device starts * to use. Underneath the surface the information is cached into an * internal buffer first. Then a notification is sent to all those * registered consumers. So then they can retrieve that buffer to * know the latest active frequency bands. Consumers that haven't * yet been registered can retrieve the information from the cache * when they register. * * Return: * 0 for success add/remove wifi frequency band. * Returns a negative error code for failure.
*/ int acpi_amd_wbrf_add_remove(struct device *dev, uint8_t action, struct wbrf_ranges_in_out *in)
{ struct acpi_device *adev; int ret;
adev = ACPI_COMPANION(dev); if (!adev) return -ENODEV;
ret = wbrf_record(adev, action, in); if (ret) return ret;
/** * acpi_amd_wbrf_supported_producer - determine if the WBRF can be enabled * for the device as a producer * * @dev: device pointer * * Check if the platform equipped with necessary implementations to * support WBRF for the device as a producer. * * Return: * true if WBRF is supported, otherwise returns false
*/ bool acpi_amd_wbrf_supported_producer(struct device *dev)
{ struct acpi_device *adev;
adev = ACPI_COMPANION(dev); if (!adev) returnfalse;
/** * acpi_amd_wbrf_supported_consumer - determine if the WBRF can be enabled * for the device as a consumer * * @dev: device pointer * * Determine if the platform equipped with necessary implementations to * support WBRF for the device as a consumer. * * Return: * true if WBRF is supported, otherwise returns false.
*/ bool acpi_amd_wbrf_supported_consumer(struct device *dev)
{ struct acpi_device *adev;
adev = ACPI_COMPANION(dev); if (!adev) returnfalse;
/** * amd_wbrf_retrieve_freq_band - retrieve current active frequency bands * * @dev: device pointer * @out: output structure containing all the active frequency bands * * Retrieve the current active frequency bands which were broadcasted * by other producers. The consumer who calls this API should take * proper actions if any of the frequency band may cause RFI with its * own frequency band used. * * Return: * 0 for getting wifi freq band successfully. * Returns a negative error code for failure.
*/ int amd_wbrf_retrieve_freq_band(struct device *dev, struct wbrf_ranges_in_out *out)
{ struct amd_wbrf_ranges_out acpi_out = {0}; struct acpi_device *adev; union acpi_object *obj; union acpi_object param; int ret = 0;
adev = ACPI_COMPANION(dev); if (!adev) return -ENODEV;
/* * The return buffer is with variable length and the format below: * number_of_entries(1 DWORD): Number of entries * start_freq of 1st entry(1 QWORD): Start frequency of the 1st entry * end_freq of 1st entry(1 QWORD): End frequency of the 1st entry * ... * ... * start_freq of the last entry(1 QWORD) * end_freq of the last entry(1 QWORD) * * Thus the buffer length is determined by the number of entries. * - For zero entry scenario, the buffer length will be 4 bytes. * - For one entry scenario, the buffer length will be 20 bytes.
*/ if (obj->buffer.length > sizeof(acpi_out) || obj->buffer.length < 4) {
dev_err(dev, "Wrong sized WBRT information");
ret = -EINVAL; goto out;
}
memcpy(&acpi_out, obj->buffer.pointer, obj->buffer.length);
/** * amd_wbrf_register_notifier - register for notifications of frequency * band update * * @nb: driver notifier block * * The consumer should register itself via this API so that it can get * notified on the frequency band updates from other producers. * * Return: * 0 for registering a consumer driver successfully. * Returns a negative error code for failure.
*/ int amd_wbrf_register_notifier(struct notifier_block *nb)
{ return blocking_notifier_chain_register(&wbrf_chain_head, nb);
}
EXPORT_SYMBOL_GPL(amd_wbrf_register_notifier);
/** * amd_wbrf_unregister_notifier - unregister for notifications of * frequency band update * * @nb: driver notifier block * * The consumer should call this API when it is longer interested with * the frequency band updates from other producers. Usually, this should * be performed during driver cleanup. * * Return: * 0 for unregistering a consumer driver. * Returns a negative error code for failure.
*/ int amd_wbrf_unregister_notifier(struct notifier_block *nb)
{ return blocking_notifier_chain_unregister(&wbrf_chain_head, nb);
}
EXPORT_SYMBOL_GPL(amd_wbrf_unregister_notifier);
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.