static int __devinit bfin_tdm_probe(struct platform_device *pdev) { int ret = 0; if (peripheral_request_list(&sport_req[sport_num][0], "soc-audio")) { pr_err("Requesting Peripherals failed\n"); return -EFAULT; } /* request DMA for SPORT */ sport_handle = sport_init(&sport_params[sport_num], 4, \ 8 * sizeof(u32), NULL); if (!sport_handle) { peripheral_free_list(&sport_req[sport_num][0]); return -ENODEV; } /* SPORT works in TDM mode */ ret = sport_set_multichannel(sport_handle, 8, 0xFF, 1); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_rx(sport_handle, IRFS, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_tx(sport_handle, ITFS, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = snd_soc_register_dai(&bf5xx_tdm_dai); if (ret) { pr_err("Failed to register DAI: %d\n", ret); goto sport_config_err; } sport_handle->private_data = &bf5xx_tdm; return 0; sport_config_err: peripheral_free_list(&sport_req[sport_num][0]); return ret; }
static int __devinit bfin_tdm_probe(struct platform_device *pdev) { struct sport_device *sport_handle; int ret; /* configure SPORT for TDM */ sport_handle = sport_init(pdev, 4, 8 * sizeof(u32), sizeof(struct bf5xx_tdm_port)); if (!sport_handle) return -ENODEV; /* SPORT works in TDM mode */ ret = sport_set_multichannel(sport_handle, 8, 0xFF, 1); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_rx(sport_handle, 0, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_tx(sport_handle, 0, 0x1F, 0, 0); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = snd_soc_register_dai(&pdev->dev, &bf5xx_tdm_dai); if (ret) { pr_err("Failed to register DAI: %d\n", ret); goto sport_config_err; } return 0; sport_config_err: sport_done(sport_handle); return ret; }
static int __devinit bf5xx_i2s_probe(struct platform_device *pdev) { struct sport_device *sport_handle; int ret; /* configure SPORT for I2S */ sport_handle = sport_init(pdev, 4, 2 * sizeof(u32), sizeof(struct bf5xx_i2s_port)); if (!sport_handle) return -ENODEV; /* register with the ASoC layers */ ret = snd_soc_register_dai(&pdev->dev, &bf5xx_i2s_dai); if (ret) { pr_err("Failed to register DAI: %d\n", ret); sport_done(sport_handle); return ret; } return 0; }
static int bf5xx_probe(struct platform_device *pdev) { u16 sport_req[][7] = {PIN_REQ_SPORT_0, PIN_REQ_SPORT_1}; if (peripheral_request_list(&sport_req[sport_num][0], "soc-audio")) { printk(KERN_ERR "Requesting Peripherals faild\n"); return -EFAULT; } #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET /* Request PB3 as reset pin */ if (gpio_request(CONFIG_SND_BF5XX_RESET_GPIO_NUM, "SND_AD198x RESET")) { printk(KERN_ERR "Failed to request GPIO_%d for reset\n", CONFIG_SND_BF5XX_RESET_GPIO_NUM); peripheral_free_list(&sport_req[sport_num][0]); return -1; } gpio_direction_output(CONFIG_SND_BF5XX_RESET_GPIO_NUM); gpio_set_value(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 1); #endif sport_handle = sport_init(&sport_params[sport_num], 2, \ 10 * sizeof(struct ac97_frame), NULL); if (!sport_handle) { peripheral_free_list(&sport_req[sport_num][0]); #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); #endif return -ENODEV; } sport_set_multichannel(sport_handle, 16, 0x1F, 1); sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1)); sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1)); return 0; }
// set_mode - change flight mode and perform any necessary initialisation // optional force parameter used to force the flight mode change (used only first time mode is set) // returns true if mode was successfully set // ACRO, STABILIZE, ALTHOLD, LAND, DRIFT and SPORT can always be set successfully but the return state of other flight modes should be checked and the caller should deal with failures appropriately bool Copter::set_mode(control_mode_t mode, mode_reason_t reason) { // boolean to record if flight mode could be set bool success = false; bool ignore_checks = !motors.armed(); // allow switching to any mode if disarmed. We rely on the arming check to perform // return immediately if we are already in the desired mode if (mode == control_mode) { prev_control_mode = control_mode; prev_control_mode_reason = control_mode_reason; control_mode_reason = reason; return true; } switch(mode) { case ACRO: #if FRAME_CONFIG == HELI_FRAME success = heli_acro_init(ignore_checks); #else success = acro_init(ignore_checks); #endif break; case STABILIZE: #if FRAME_CONFIG == HELI_FRAME success = heli_stabilize_init(ignore_checks); #else success = stabilize_init(ignore_checks); #endif break; case ALT_HOLD: success = althold_init(ignore_checks); break; case AUTO: success = auto_init(ignore_checks); break; case CIRCLE: success = circle_init(ignore_checks); break; case LOITER: success = loiter_init(ignore_checks); break; case GUIDED: success = guided_init(ignore_checks); break; case LAND: success = land_init(ignore_checks); break; case RTL: success = rtl_init(ignore_checks); break; case DRIFT: success = drift_init(ignore_checks); break; case SPORT: success = sport_init(ignore_checks); break; case ALT_POS: success = altpos_init(ignore_checks); break; case FLIP: success = flip_init(ignore_checks); break; #if AUTOTUNE_ENABLED == ENABLED case AUTOTUNE: success = autotune_init(ignore_checks); break; #endif #if POSHOLD_ENABLED == ENABLED case POSHOLD: success = poshold_init(ignore_checks); break; #endif case BRAKE: success = brake_init(ignore_checks); break; case THROW: success = throw_init(ignore_checks); break; case AVOID_ADSB: success = avoid_adsb_init(ignore_checks); break; case GUIDED_NOGPS: success = guided_nogps_init(ignore_checks); break; default: success = false; break; } // update flight mode if (success) { // perform any cleanup required by previous flight mode exit_mode(control_mode, mode); prev_control_mode = control_mode; prev_control_mode_reason = control_mode_reason; control_mode = mode; control_mode_reason = reason; DataFlash.Log_Write_Mode(control_mode, control_mode_reason); adsb.set_is_auto_mode((mode == AUTO) || (mode == RTL) || (mode == GUIDED)); #if AC_FENCE == ENABLED // pilot requested flight mode change during a fence breach indicates pilot is attempting to manually recover // this flight mode change could be automatic (i.e. fence, battery, GPS or GCS failsafe) // but it should be harmless to disable the fence temporarily in these situations as well fence.manual_recovery_start(); #endif }else{ // Log error that we failed to enter desired flight mode Log_Write_Error(ERROR_SUBSYSTEM_FLIGHT_MODE,mode); } // update notify object if (success) { notify_flight_mode(control_mode); } // return success or failure return success; }
static int bf5xx_ac97_probe(struct platform_device *pdev, struct snd_soc_dai *dai) { int ret = 0; cmd_count = (int *)get_zeroed_page(GFP_KERNEL); if (cmd_count == NULL) return -ENOMEM; if (peripheral_request_list(sport_req[sport_num], "soc-audio")) { pr_err("Requesting Peripherals failed\n"); ret = -EFAULT; goto peripheral_err; } #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET /* Request PB3 as reset pin */ if (gpio_request(CONFIG_SND_BF5XX_RESET_GPIO_NUM, "SND_AD198x RESET")) { pr_err("Failed to request GPIO_%d for reset\n", CONFIG_SND_BF5XX_RESET_GPIO_NUM); ret = -1; goto gpio_err; } gpio_direction_output(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 1); #endif sport_handle = sport_init(&sport_params[sport_num], 2, \ sizeof(struct ac97_frame), NULL); if (!sport_handle) { ret = -ENODEV; goto sport_err; } /*SPORT works in TDM mode to simulate AC97 transfers*/ #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) ret = sport_set_multichannel(sport_handle, 16, 0x3FF, 1); #else ret = sport_set_multichannel(sport_handle, 16, 0x1F, 1); #endif if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } return 0; sport_config_err: kfree(sport_handle); sport_err: #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); gpio_err: #endif peripheral_free_list(sport_req[sport_num]); peripheral_err: free_page((unsigned long)cmd_count); cmd_count = NULL; return ret; }
static int __devinit asoc_bfin_ac97_probe(struct platform_device *pdev) { struct sport_device *sport_handle; int ret; #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET /* Request PB3 as reset pin */ if (gpio_request(CONFIG_SND_BF5XX_RESET_GPIO_NUM, "SND_AD198x RESET")) { pr_err("Failed to request GPIO_%d for reset\n", CONFIG_SND_BF5XX_RESET_GPIO_NUM); ret = -1; goto gpio_err; } gpio_direction_output(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 1); #endif sport_handle = sport_init(pdev, 2, sizeof(struct ac97_frame), PAGE_SIZE); if (!sport_handle) { ret = -ENODEV; goto sport_err; } /*SPORT works in TDM mode to simulate AC97 transfers*/ #if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) ret = sport_set_multichannel(sport_handle, 16, 0x3FF, 1); #else ret = sport_set_multichannel(sport_handle, 16, 0x1F, 1); #endif if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1)); if (ret) { pr_err("SPORT is busy!\n"); ret = -EBUSY; goto sport_config_err; } ret = snd_soc_register_dai(&pdev->dev, &bfin_ac97_dai); if (ret) { pr_err("Failed to register DAI: %d\n", ret); goto sport_config_err; } ac97_sport_handle = sport_handle; return 0; sport_config_err: sport_done(sport_handle); sport_err: #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); gpio_err: #endif return ret; }