mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-10 08:03:04 -04:00
sdmmc_host: trigger LED on disk activity
Change-Id: Ic7c43de01f381b7d87ed6b234fa63d5276ae31a5
This commit is contained in:
parent
cdad8cde64
commit
94a0fe608a
2 changed files with 27 additions and 0 deletions
|
|
@ -21,6 +21,7 @@
|
|||
#include "system.h"
|
||||
#include "storage.h"
|
||||
#include "disk_cache.h"
|
||||
#include "led.h"
|
||||
#include "debug.h"
|
||||
#include "panic.h"
|
||||
#include "logf.h"
|
||||
|
|
@ -48,6 +49,29 @@ DECLARE_FIRST_DRIVE(int sdmmc_mmc_first_drive);
|
|||
static volatile long sdmmc_mmc_last_activity;
|
||||
#endif
|
||||
|
||||
static bool sdmmc_host_any_active(void)
|
||||
{
|
||||
#if CONFIG_STORAGE & STORAGE_SD
|
||||
for (size_t i = 0; i < ARRAYLEN(sdmmc_sd_hosts); ++i)
|
||||
if (sdmmc_sd_hosts[i]->led_active)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#if CONFIG_STORAGE & STORAGE_MMC
|
||||
for (size_t i = 0; i < ARRAYLEN(sdmmc_mmc_hosts); ++i)
|
||||
if (sdmmc_mmc_hosts[i]->led_active)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void sdmmc_host_set_led(struct sdmmc_host *host, bool on)
|
||||
{
|
||||
host->led_active = on;
|
||||
led(sdmmc_host_any_active());
|
||||
}
|
||||
|
||||
static int sdmmc_host_get_logical_drive(struct sdmmc_host *host)
|
||||
{
|
||||
switch (host->config.type)
|
||||
|
|
@ -734,6 +758,7 @@ static int sdmmc_host_transfer(struct sdmmc_host *host,
|
|||
int rc = -1;
|
||||
|
||||
mutex_lock(&host->lock);
|
||||
sdmmc_host_set_led(host, true);
|
||||
|
||||
if (!host->enabled)
|
||||
goto out;
|
||||
|
|
@ -843,6 +868,7 @@ static int sdmmc_host_transfer(struct sdmmc_host *host,
|
|||
}
|
||||
|
||||
out:
|
||||
sdmmc_host_set_led(host, false);
|
||||
mutex_unlock(&host->lock);
|
||||
return rc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ struct sdmmc_host
|
|||
bool initialized : 1;
|
||||
bool is_hcs_card : 1;
|
||||
bool use_cmd23 : 1;
|
||||
bool led_active : 1; /* LED active may be read without lock */
|
||||
|
||||
/* Controller implemented by the target */
|
||||
const struct sdmmc_controller_ops *ops;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue