static inline void perform_work(struct queue *q, bladerf_module module) { struct queue_entry *e = peek_next_retune(q); if (e == NULL) { return; } switch (e->state) { case ENTRY_STATE_NEW: /* Load the fast lock profile into the RFFE */ profile_load(module, e->profile); /* Schedule the retune */ e->state = ENTRY_STATE_SCHEDULED; tamer_schedule(module, e->timestamp); break; case ENTRY_STATE_SCHEDULED: /* Nothing to do. * Waiting for this entry to become ready */ break; case ENTRY_STATE_READY: /* Activate the fast lock profile for this retune */ profile_activate(module, e->profile); /* Drop the item from the queue */ dequeue_retune(q, NULL); break; default: INCREMENT_ERROR_COUNT(); break; } }
void pkt_retune2(struct pkt_buf *b) { int status = -1; bladerf_module module; uint8_t flags; uint64_t timestamp; uint64_t start_time; uint64_t end_time; uint64_t duration = 0; uint16_t nios_profile; uint8_t rffe_profile; uint8_t port; uint8_t spdt; fastlock_profile *profile; flags = NIOS_PKT_RETUNE2_RESP_FLAG_SUCCESS; nios_pkt_retune2_unpack(b->req, &module, ×tamp, &nios_profile, &rffe_profile, &port, &spdt); switch (module) { case BLADERF_MODULE_RX: profile = &fastlocks_rx[nios_profile]; break; case BLADERF_MODULE_TX: profile = &fastlocks_tx[nios_profile]; break; default: profile = NULL; } if (profile == NULL) { INCREMENT_ERROR_COUNT(); status = -1; } else { /* Update the fastlock profile data */ profile->profile_num = rffe_profile; profile->port = port; profile->spdt = spdt; } start_time = time_tamer_read(module); if (timestamp == NIOS_PKT_RETUNE2_NOW) { /* Fire off this retune operation now */ switch (module) { case BLADERF_MODULE_RX: case BLADERF_MODULE_TX: /* Load the profile data into RFFE memory */ profile_load(module, profile); /* Activate the fast lock profile for this retune */ profile_activate(module, profile); flags |= NIOS_PKT_RETUNE2_RESP_FLAG_TSVTUNE_VALID; status = 0; break; default: INCREMENT_ERROR_COUNT(); status = -1; } } else if (timestamp == NIOS_PKT_RETUNE2_CLEAR_QUEUE) { switch (module) { case BLADERF_MODULE_RX: reset_queue(&rx_queue); status = 0; break; case BLADERF_MODULE_TX: reset_queue(&tx_queue); status = 0; break; default: INCREMENT_ERROR_COUNT(); status = -1; } } else { uint8_t queue_size; switch (module) { case BLADERF_MODULE_RX: queue_size = enqueue_retune(&rx_queue, profile, timestamp); profile_load_scheduled(&rx_queue, module); break; case BLADERF_MODULE_TX: queue_size = enqueue_retune(&tx_queue, profile, timestamp); profile_load_scheduled(&tx_queue, module); break; default: INCREMENT_ERROR_COUNT(); queue_size = QUEUE_FULL; } if (queue_size == QUEUE_FULL) { status = -1; } else { status = 0; } } end_time = time_tamer_read(module); duration = end_time - start_time; if (status != 0) { flags &= ~(NIOS_PKT_RETUNE2_RESP_FLAG_SUCCESS); } nios_pkt_retune2_resp_pack(b->resp, duration, flags); }
int main(int argc, char **argv) { GOptionContext *context; RoccatDevice *kovaplus; GError *local_error = NULL; int retval = EXIT_SUCCESS; KovaplusRmp *rmp = NULL; roccat_secure(); roccat_textdomain(); context = commandline_parse(&argc, &argv); if (parameter_just_print_version) { g_print(VERSION_STRING "\n"); goto exit1; } #if !(GLIB_CHECK_VERSION(2, 36, 0)) g_type_init(); #endif kovaplus = kovaplus_device_first(); if (kovaplus == NULL) { g_critical(_("No %s found."), KOVAPLUS_DEVICE_NAME); retval = EXIT_FAILURE; goto exit1; } if (parameter_just_activate_driver_state) { if (!kovaplus_device_state_write(kovaplus, KOVAPLUS_DEVICE_STATE_STATE_ON, &local_error)) { g_critical(_("Could not activate driver state: %s"), local_error->message); retval = EXIT_FAILURE; } goto exit2; } if (parameter_just_deactivate_driver_state) { if (!kovaplus_device_state_write(kovaplus, KOVAPLUS_DEVICE_STATE_STATE_OFF, &local_error)) { g_critical(_("Could not deactivate driver state: %s"), local_error->message); retval = EXIT_FAILURE; } goto exit2; } if (parameter_just_print_actual_profile) { if (!print_actual_profile(kovaplus, &local_error)) { g_critical(_("Could not print actual profile: %s"), local_error->message); retval = EXIT_FAILURE; } goto exit2; } if (parameter_just_reset) { if (!reset(kovaplus, &local_error)) { g_critical(_("Could not reset device: %s"), local_error->message); retval = EXIT_FAILURE; } goto exit2; } if (parameter_read_firmware) { if (!print_firmware(kovaplus, &local_error)) { g_critical(_("Could not print firmware version: %s"), local_error->message); retval = EXIT_FAILURE; goto exit2; } } if (parameter_load != -1) { rmp = kovaplus_rmp_load(kovaplus, parameter_load - 1, &local_error); if (!rmp) { g_critical(_("Could not load profile %i: %s"), parameter_load, local_error->message); retval = EXIT_FAILURE; goto exit2; } } else if (parameter_in_rmp) { rmp = kovaplus_rmp_read_with_path(parameter_in_rmp, &local_error); if (!rmp) { g_critical(_("Could not read rmp %s: %s"), parameter_in_rmp, local_error->message); retval = EXIT_FAILURE; goto exit2; } } else rmp = kovaplus_rmp_dup(kovaplus_default_rmp()); kovaplus_rmp_set_modified(rmp); if (parameter_save != -1) { if (!kovaplus_rmp_save(kovaplus, rmp, parameter_save - 1, &local_error)) { g_critical(_("Could not save profile %i: %s"), parameter_save, local_error->message); retval = EXIT_FAILURE; goto exit3; } kovaplus_dbus_emit_profile_data_changed_outside_instant(parameter_save); } if (parameter_out_rmp) { if (!kovaplus_rmp_write_with_path(parameter_out_rmp, rmp, &local_error)) { g_critical(_("Could not write rmp %s: %s"), parameter_out_rmp, local_error->message); retval = EXIT_FAILURE; goto exit3; } } if (parameter_activate_profile != -1) { if (!profile_activate(kovaplus, parameter_activate_profile, &local_error)) { g_critical(_("Could not activate profile %i: %s"), parameter_activate_profile, local_error->message); retval = EXIT_FAILURE; goto exit3; } kovaplus_dbus_emit_profile_changed_outside_instant(parameter_activate_profile); } exit3: kovaplus_rmp_free(rmp); exit2: g_object_unref(G_OBJECT(kovaplus)); exit1: commandline_free(context); g_clear_error(&local_error); exit(retval); }