mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 15:40:28 +00:00
Cleanups
This commit is contained in:
parent
465e84d60c
commit
2ecb6e654e
@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
#include "../../configuration.h"
|
#include "../../configuration.h"
|
||||||
#include "../../retroarch.h"
|
#include "../../retroarch.h"
|
||||||
#include "../../verbosity.h"
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -15,6 +13,7 @@ typedef struct
|
|||||||
int map[MAX_LEDS];
|
int map[MAX_LEDS];
|
||||||
} overlayled_t;
|
} overlayled_t;
|
||||||
|
|
||||||
|
/* TODO/FIXME - static globals */
|
||||||
static overlayled_t curins;
|
static overlayled_t curins;
|
||||||
static overlayled_t *cur = &curins;
|
static overlayled_t *cur = &curins;
|
||||||
|
|
||||||
@ -23,13 +22,10 @@ static void overlay_init(void)
|
|||||||
int i;
|
int i;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
RARCH_LOG("[LED]: overlay LED driver init\n");
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_LEDS; i++)
|
for (i = 0; i < MAX_LEDS; i++)
|
||||||
{
|
{
|
||||||
cur->setup[i] = 0;
|
cur->setup[i] = 0;
|
||||||
cur->map[i] = settings->uints.led_map[i];
|
cur->map[i] = settings->uints.led_map[i];
|
||||||
RARCH_LOG("[LED]: overlay map[%d]=%d\n",i,cur->map[i]);
|
|
||||||
|
|
||||||
if (cur->map[i] >= 0)
|
if (cur->map[i] >= 0)
|
||||||
input_overlay_set_visibility(cur->map[i],
|
input_overlay_set_visibility(cur->map[i],
|
||||||
@ -39,17 +35,13 @@ static void overlay_init(void)
|
|||||||
|
|
||||||
static void overlay_free(void)
|
static void overlay_free(void)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[LED]: overlay LED driver free\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void overlay_set(int led, int state)
|
static void overlay_set(int led, int state)
|
||||||
{
|
{
|
||||||
int gpio = 0;
|
int gpio = 0;
|
||||||
if ((led < 0) || (led >= MAX_LEDS))
|
if ((led < 0) || (led >= MAX_LEDS))
|
||||||
{
|
|
||||||
RARCH_WARN("[LED]: invalid led %d\n", led);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
gpio = cur->map[led];
|
gpio = cur->map[led];
|
||||||
|
|
||||||
@ -59,8 +51,6 @@ static void overlay_set(int led, int state)
|
|||||||
input_overlay_set_visibility(gpio,
|
input_overlay_set_visibility(gpio,
|
||||||
state ? OVERLAY_VISIBILITY_VISIBLE
|
state ? OVERLAY_VISIBILITY_VISIBLE
|
||||||
: OVERLAY_VISIBILITY_HIDDEN);
|
: OVERLAY_VISIBILITY_HIDDEN);
|
||||||
|
|
||||||
RARCH_LOG("[LED]: set visibility %d %d\n", gpio, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const led_driver_t overlay_led_driver = {
|
const led_driver_t overlay_led_driver = {
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "../led_defines.h"
|
#include "../led_defines.h"
|
||||||
|
|
||||||
#include "../../configuration.h"
|
#include "../../configuration.h"
|
||||||
#include "../../verbosity.h"
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -26,6 +25,7 @@ typedef struct
|
|||||||
int map[MAX_LEDS];
|
int map[MAX_LEDS];
|
||||||
} rpiled_t;
|
} rpiled_t;
|
||||||
|
|
||||||
|
/* TODO/FIXME - static globals */
|
||||||
static rpiled_t curins;
|
static rpiled_t curins;
|
||||||
static rpiled_t *cur = &curins;
|
static rpiled_t *cur = &curins;
|
||||||
|
|
||||||
@ -41,7 +41,6 @@ static void rpi_init(void)
|
|||||||
{
|
{
|
||||||
cur->setup[i] = 0;
|
cur->setup[i] = 0;
|
||||||
cur->map[i] = settings->uints.led_map[i];
|
cur->map[i] = settings->uints.led_map[i];
|
||||||
RARCH_LOG("[LED]: rpi map[%d]=%d\n", i, cur->map[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,11 +55,9 @@ static int set_gpio(int gpio, int value)
|
|||||||
snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%d/value", gpio);
|
snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%d/value", gpio);
|
||||||
fp = fopen(buf, "w");
|
fp = fopen(buf, "w");
|
||||||
|
|
||||||
if(!fp)
|
/* Failed to set GPIO? */
|
||||||
{
|
if (!fp)
|
||||||
RARCH_WARN("[LED]: failed to set GPIO %d\n", gpio);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fp, "%d\n", value ? 1 : 0);
|
fprintf(fp, "%d\n", value ? 1 : 0);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@ -79,11 +76,9 @@ static int setup_gpio(int gpio)
|
|||||||
snprintf(buf, sizeof(buf), "/sys/class/gpio/export");
|
snprintf(buf, sizeof(buf), "/sys/class/gpio/export");
|
||||||
fp = fopen(buf, "w");
|
fp = fopen(buf, "w");
|
||||||
|
|
||||||
if(!fp)
|
/* Failed to export GPIO? */
|
||||||
{
|
if (!fp)
|
||||||
RARCH_WARN("[LED]: failed to export GPIO %d\n", gpio);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fp,"%d\n", gpio);
|
fprintf(fp,"%d\n", gpio);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@ -92,12 +87,9 @@ static int setup_gpio(int gpio)
|
|||||||
fp = fopen(buf, "w");
|
fp = fopen(buf, "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!fp)
|
/* Failed to set direction GPIO? */
|
||||||
{
|
if (!fp)
|
||||||
RARCH_WARN("[LED]: failed to set direction GPIO %d\n",
|
|
||||||
gpio);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fp, "out\n");
|
fprintf(fp, "out\n");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@ -108,33 +100,18 @@ static void rpi_set(int led, int state)
|
|||||||
{
|
{
|
||||||
int gpio = 0;
|
int gpio = 0;
|
||||||
|
|
||||||
|
/* Invalid LED? */
|
||||||
if((led < 0) || (led >= MAX_LEDS))
|
if((led < 0) || (led >= MAX_LEDS))
|
||||||
{
|
|
||||||
RARCH_WARN("[LED]: invalid led %d\n", led);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
gpio = cur->map[led];
|
gpio = cur->map[led];
|
||||||
if(gpio <= 0)
|
if(gpio <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(cur->setup[led] == 0)
|
if(cur->setup[led] == 0)
|
||||||
{
|
|
||||||
RARCH_LOG("[LED]: rpi setup led %d gpio %d\n",
|
|
||||||
led, gpio, state);
|
|
||||||
cur->setup[led] = setup_gpio(gpio);
|
cur->setup[led] = setup_gpio(gpio);
|
||||||
if(cur->setup[led] <= 0)
|
|
||||||
{
|
|
||||||
RARCH_WARN("[LED]: failed to setup led %d gpio %d\n",
|
|
||||||
led, gpio);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(cur->setup[led] > 0)
|
if(cur->setup[led] > 0)
|
||||||
{
|
|
||||||
RARCH_LOG("[LED]: rpi LED driver set led %d gpio %d = %d\n",
|
|
||||||
led, gpio, state);
|
|
||||||
set_gpio(gpio, state);
|
set_gpio(gpio, state);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const led_driver_t rpi_led_driver = {
|
const led_driver_t rpi_led_driver = {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
|
||||||
#include "led_driver.h"
|
#include "led_driver.h"
|
||||||
#include "../verbosity.h"
|
|
||||||
|
|
||||||
static const led_driver_t *current_led_driver = NULL;
|
static const led_driver_t *current_led_driver = NULL;
|
||||||
|
|
||||||
@ -50,9 +49,6 @@ void led_driver_init(const char *led_driver)
|
|||||||
current_led_driver = &rpi_led_driver;
|
current_led_driver = &rpi_led_driver;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RARCH_LOG("[LED]: LED driver = '%s' %p\n",
|
|
||||||
drivername, current_led_driver);
|
|
||||||
|
|
||||||
if (current_led_driver)
|
if (current_led_driver)
|
||||||
(*current_led_driver->init)();
|
(*current_led_driver->init)();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user