Re: [PATCH] drivers: input: joystick: Add PSX(Play Staion 1/2) pad with SPI driver Add PSX(Play Staion 1/2) pad with SPI driver. Pads can be connected directry SPI bus.
Hi, Thank you for your submission. On Mon, Apr 24, 2017 at 09:48:05AM +0900, AZO wrote: > --- We would need a better patch description and your signed-off-by, please. > drivers/input/joystick/Kconfig | 9 + > drivers/input/joystick/Makefile | 1 + > drivers/input/joystick/psxpad-spi.c | 679 > > 3 files changed, 689 insertions(+) > create mode 100644 drivers/input/joystick/psxpad-spi.c > > diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig > index 4215b5382092..bd36cbc43a34 100644 > --- a/drivers/input/joystick/Kconfig > +++ b/drivers/input/joystick/Kconfig > @@ -330,4 +330,13 @@ config JOYSTICK_MAPLE > To compile this as a module choose M here: the module will be called > maplecontrol. > > +config JOYSTICK_PSXPAD_SPI > + tristate "PSX(Play Station 1/2) pad with SPI Bus Driver" Please add space before opening parenthesis here and elsewhere. > + depends on INPUT_POLLDEV && SPI > + help > + Say Y here if you connect PSX(PS1/2) pad with SPI Interface. > + > + To compile this driver as a module, choose M here: the > + module will be called psxpad-spi. > + > endif > diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile > index 92dc0de9dfed..2b71848cdc13 100644 > --- a/drivers/input/joystick/Makefile > +++ b/drivers/input/joystick/Makefile > @@ -32,4 +32,5 @@ obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o > obj-$(CONFIG_JOYSTICK_XPAD) += xpad.o > obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o > obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o > +obj-$(CONFIG_JOYSTICK_PSXPAD_SPI)+= psxpad-spi.o Please insert into alphabetically-suitable place. > > diff --git a/drivers/input/joystick/psxpad-spi.c > b/drivers/input/joystick/psxpad-spi.c > new file mode 100644 > index ..c5b497b2352e > --- /dev/null > +++ b/drivers/input/joystick/psxpad-spi.c > @@ -0,0 +1,679 @@ > +/* > + * PSX(Play Station 1/2) pad (SPI Interface) > + * > + * Copyright (C) 2017 AZO> + * Licensed under the GPL-2 or later. > + * > + * PSX pad plug (not socket) > + * 123 456 789 > + * (...|...|...) > + * > + * 1: DAT -> MISO (pullup with 1k owm to 3.3V) > + * 2: CMD -> MOSI > + * 3: 9V (for motor, if not use N.C.) > + * 4: GND > + * 5: 3.3V > + * 6: Attention -> CS(SS) > + * 7: SCK -> SCK > + * 8: N.C. > + * 9: ACK -> N.C. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +//#define PSXPAD_ENABLE_ANALOG2 > +#define PSXPAD_ENABLE_FF FF should either be enabled unconditionally, or expressed via Kconfig dependency. > + > +enum { > + PSXPAD_SPI_SPEED_125KHZ = 0, > + PSXPAD_SPI_SPEED_250KHZ, > + PSXPAD_SPI_SPEED_500KHZ, > + PSXPAD_SPI_SPEED_UNKNOWN > +}; > + > +#define PSXPAD_DEFAULT_SPI_DELAY 100 > +#define PSXPAD_DEFAULT_SPI_SPEED PSXPAD_SPI_SPEED_125KHZ > +#define PSXPAD_DEFAULT_INTERVAL 16 > +#define PSXPAD_DEFAULT_INTERVAL_MIN 8 > +#define PSXPAD_DEFAULT_INTERVAL_MAX 32 > +#define PSXPAD_DEFAULT_ADMODEtrue > +#define PSXPAD_DEFAULT_INPUT_PHYSIZE 32 > + > +#define REVERSE_BIT(x) x) & 0x80) >> 7) | (((x) & 0x40) >> 5) | (((x) & > 0x20) >> 3) | (((x) & 0x10) >> 1) | (((x) & 0x08) << 1) | (((x) & 0x04) << 3) > | (((x) & 0x02) << 5) | (((x) & 0x01) << 7)) > + > +enum { > + PSXPAD_KEYSTATE_TYPE_DIGITAL = 0, > + PSXPAD_KEYSTATE_TYPE_ANALOG1, > +#ifdef PSXPAD_ENABLE_ANALOG2 > + PSXPAD_KEYSTATE_TYPE_ANALOG2, > +#endif /* PSXPAD_ENABLE_ANALOG2 */ > + PSXPAD_KEYSTATE_TYPE_UNKNOWN > +}; > + > +#ifdef PSXPAD_ENABLE_ANALOG2 > +static const u8 PSX_CMD_INIT_PRESSURE[] = {0x01, 0x40, 0x00, 0x00, > 0x02, 0x00, 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_ALL_PRESSURE[] = {0x01, 0x4F, 0x00, 0xFF, > 0xFF, 0x03, 0x00, 0x00, 0x00}; > +#endif /* PSXPAD_ENABLE_ANALOG2 */ > +static const u8 PSX_CMD_POLL[] = {0x01, 0x42, 0x00, 0x00, > 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > 0x00, 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_ENTER_CFG[] = {0x01, 0x43, 0x00, 0x01, 0x00, 0x00, > 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_EXIT_CFG[] = {0x01, 0x43, 0x00, 0x00, 0x5A, 0x5A, > 0x5A, 0x5A, 0x5A}; > +static const u8 PSX_CMD_ENABLE_MOTOR[] = {0x01, 0x4D, 0x00, 0xFF, > 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; > +static const u8 PSX_CMD_AD_MODE[]= {0x01, 0x44, 0x00, 0x01, 0x00, 0x00, > 0x00, 0x00, 0x00}; > + > +struct psxpad_keystate { > + int type; > + /* PSXPAD_KEYSTATE_TYPE_DIGITAL */ > + bool select; > + bool start; > + bool up; > + bool right; > + bool down; > + bool left; > + bool l2; > + bool r2; > + bool l1; > + bool r1; > + bool triangle; > + bool circle; > + bool cross; > + bool square; > + /* PSXPAD_KEYSTATE_TYPE_ANALOG1 */ > + u8
Re: [PATCH] drivers: input: joystick: Add PSX(Play Staion 1/2) pad with SPI driver Add PSX(Play Staion 1/2) pad with SPI driver. Pads can be connected directry SPI bus.
Hi, Thank you for your submission. On Mon, Apr 24, 2017 at 09:48:05AM +0900, AZO wrote: > --- We would need a better patch description and your signed-off-by, please. > drivers/input/joystick/Kconfig | 9 + > drivers/input/joystick/Makefile | 1 + > drivers/input/joystick/psxpad-spi.c | 679 > > 3 files changed, 689 insertions(+) > create mode 100644 drivers/input/joystick/psxpad-spi.c > > diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig > index 4215b5382092..bd36cbc43a34 100644 > --- a/drivers/input/joystick/Kconfig > +++ b/drivers/input/joystick/Kconfig > @@ -330,4 +330,13 @@ config JOYSTICK_MAPLE > To compile this as a module choose M here: the module will be called > maplecontrol. > > +config JOYSTICK_PSXPAD_SPI > + tristate "PSX(Play Station 1/2) pad with SPI Bus Driver" Please add space before opening parenthesis here and elsewhere. > + depends on INPUT_POLLDEV && SPI > + help > + Say Y here if you connect PSX(PS1/2) pad with SPI Interface. > + > + To compile this driver as a module, choose M here: the > + module will be called psxpad-spi. > + > endif > diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile > index 92dc0de9dfed..2b71848cdc13 100644 > --- a/drivers/input/joystick/Makefile > +++ b/drivers/input/joystick/Makefile > @@ -32,4 +32,5 @@ obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o > obj-$(CONFIG_JOYSTICK_XPAD) += xpad.o > obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o > obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o > +obj-$(CONFIG_JOYSTICK_PSXPAD_SPI)+= psxpad-spi.o Please insert into alphabetically-suitable place. > > diff --git a/drivers/input/joystick/psxpad-spi.c > b/drivers/input/joystick/psxpad-spi.c > new file mode 100644 > index ..c5b497b2352e > --- /dev/null > +++ b/drivers/input/joystick/psxpad-spi.c > @@ -0,0 +1,679 @@ > +/* > + * PSX(Play Station 1/2) pad (SPI Interface) > + * > + * Copyright (C) 2017 AZO > + * Licensed under the GPL-2 or later. > + * > + * PSX pad plug (not socket) > + * 123 456 789 > + * (...|...|...) > + * > + * 1: DAT -> MISO (pullup with 1k owm to 3.3V) > + * 2: CMD -> MOSI > + * 3: 9V (for motor, if not use N.C.) > + * 4: GND > + * 5: 3.3V > + * 6: Attention -> CS(SS) > + * 7: SCK -> SCK > + * 8: N.C. > + * 9: ACK -> N.C. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +//#define PSXPAD_ENABLE_ANALOG2 > +#define PSXPAD_ENABLE_FF FF should either be enabled unconditionally, or expressed via Kconfig dependency. > + > +enum { > + PSXPAD_SPI_SPEED_125KHZ = 0, > + PSXPAD_SPI_SPEED_250KHZ, > + PSXPAD_SPI_SPEED_500KHZ, > + PSXPAD_SPI_SPEED_UNKNOWN > +}; > + > +#define PSXPAD_DEFAULT_SPI_DELAY 100 > +#define PSXPAD_DEFAULT_SPI_SPEED PSXPAD_SPI_SPEED_125KHZ > +#define PSXPAD_DEFAULT_INTERVAL 16 > +#define PSXPAD_DEFAULT_INTERVAL_MIN 8 > +#define PSXPAD_DEFAULT_INTERVAL_MAX 32 > +#define PSXPAD_DEFAULT_ADMODEtrue > +#define PSXPAD_DEFAULT_INPUT_PHYSIZE 32 > + > +#define REVERSE_BIT(x) x) & 0x80) >> 7) | (((x) & 0x40) >> 5) | (((x) & > 0x20) >> 3) | (((x) & 0x10) >> 1) | (((x) & 0x08) << 1) | (((x) & 0x04) << 3) > | (((x) & 0x02) << 5) | (((x) & 0x01) << 7)) > + > +enum { > + PSXPAD_KEYSTATE_TYPE_DIGITAL = 0, > + PSXPAD_KEYSTATE_TYPE_ANALOG1, > +#ifdef PSXPAD_ENABLE_ANALOG2 > + PSXPAD_KEYSTATE_TYPE_ANALOG2, > +#endif /* PSXPAD_ENABLE_ANALOG2 */ > + PSXPAD_KEYSTATE_TYPE_UNKNOWN > +}; > + > +#ifdef PSXPAD_ENABLE_ANALOG2 > +static const u8 PSX_CMD_INIT_PRESSURE[] = {0x01, 0x40, 0x00, 0x00, > 0x02, 0x00, 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_ALL_PRESSURE[] = {0x01, 0x4F, 0x00, 0xFF, > 0xFF, 0x03, 0x00, 0x00, 0x00}; > +#endif /* PSXPAD_ENABLE_ANALOG2 */ > +static const u8 PSX_CMD_POLL[] = {0x01, 0x42, 0x00, 0x00, > 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > 0x00, 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_ENTER_CFG[] = {0x01, 0x43, 0x00, 0x01, 0x00, 0x00, > 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_EXIT_CFG[] = {0x01, 0x43, 0x00, 0x00, 0x5A, 0x5A, > 0x5A, 0x5A, 0x5A}; > +static const u8 PSX_CMD_ENABLE_MOTOR[] = {0x01, 0x4D, 0x00, 0xFF, > 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; > +static const u8 PSX_CMD_AD_MODE[]= {0x01, 0x44, 0x00, 0x01, 0x00, 0x00, > 0x00, 0x00, 0x00}; > + > +struct psxpad_keystate { > + int type; > + /* PSXPAD_KEYSTATE_TYPE_DIGITAL */ > + bool select; > + bool start; > + bool up; > + bool right; > + bool down; > + bool left; > + bool l2; > + bool r2; > + bool l1; > + bool r1; > + bool triangle; > + bool circle; > + bool cross; > + bool square; > + /* PSXPAD_KEYSTATE_TYPE_ANALOG1 */ > + u8 l3; > + u8 r3; >
Re: [RE][PATCH] drivers: input: joystick: Add PSX(Play Staion 1/2) pad with SPI driver Add PSX(Play Staion 1/2) pad with SPI driver. Pads can be connected directry SPI bus.
2017-04-21 1:15 GMT+02:00 AZO: > To Linux kernel input driver mainteners > > I mailed to mainteners a week ago. > Please can anyone answer? You should send the email directly to the maintainers in addition to the mailing list. You can use the get_maintainer.pl script to know who that is. > > Regard. > > = > AZO
Re: [RE][PATCH] drivers: input: joystick: Add PSX(Play Staion 1/2) pad with SPI driver Add PSX(Play Staion 1/2) pad with SPI driver. Pads can be connected directry SPI bus.
2017-04-21 1:15 GMT+02:00 AZO : > To Linux kernel input driver mainteners > > I mailed to mainteners a week ago. > Please can anyone answer? You should send the email directly to the maintainers in addition to the mailing list. You can use the get_maintainer.pl script to know who that is. > > Regard. > > = > AZO
[RE][PATCH] drivers: input: joystick: Add PSX(Play Staion 1/2) pad with SPI driver Add PSX(Play Staion 1/2) pad with SPI driver. Pads can be connected directry SPI bus.
To Linux kernel input driver mainteners I mailed to mainteners a week ago. Please can anyone answer? Regard. = AZO2017-04-14 13:28 GMT+09:00 AZO : > --- > drivers/input/joystick/Kconfig | 11 +- > drivers/input/joystick/Makefile | 1 + > drivers/input/joystick/psxpad-spi.c | 679 > > 3 files changed, 690 insertions(+), 1 deletion(-) > create mode 100644 drivers/input/joystick/psxpad-spi.c > > diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig > index 4215b53..6e38a74 100644 > --- a/drivers/input/joystick/Kconfig > +++ b/drivers/input/joystick/Kconfig > @@ -330,4 +330,13 @@ config JOYSTICK_MAPLE > To compile this as a module choose M here: the module will be called > maplecontrol. > > -endif > +config JOYSTICK_PSXPAD_SPI > + tristate "PSX(Play Station 1/2) pad with SPI Bus Driver" > + depends on INPUT_POLLDEV && SPI > + help > + Say Y here if you connect PSX(PS1/2) pad with SPI Interface. > + > + To compile this driver as a module, choose M here: the > + module will be called psxpad-spi. > + > +endifendif > diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile > index 92dc0de..2b71848 100644 > --- a/drivers/input/joystick/Makefile > +++ b/drivers/input/joystick/Makefile > @@ -32,4 +32,5 @@ obj-$(CONFIG_JOYSTICK_WARRIOR)+= warrior.o > obj-$(CONFIG_JOYSTICK_XPAD)+= xpad.o > obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o > obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o > +obj-$(CONFIG_JOYSTICK_PSXPAD_SPI) += psxpad-spi.o > > diff --git a/drivers/input/joystick/psxpad-spi.c > b/drivers/input/joystick/psxpad-spi.c > new file mode 100644 > index 000..c5b497b > --- /dev/null > +++ b/drivers/input/joystick/psxpad-spi.c > @@ -0,0 +1,679 @@ > +/* > + * PSX(Play Station 1/2) pad (SPI Interface) > + * > + * Copyright (C) 2017 AZO > + * Licensed under the GPL-2 or later. > + * > + * PSX pad plug (not socket) > + * 123 456 789 > + * (...|...|...) > + * > + * 1: DAT -> MISO (pullup with 1k owm to 3.3V) > + * 2: CMD -> MOSI > + * 3: 9V (for motor, if not use N.C.) > + * 4: GND > + * 5: 3.3V > + * 6: Attention -> CS(SS) > + * 7: SCK -> SCK > + * 8: N.C. > + * 9: ACK -> N.C. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +//#define PSXPAD_ENABLE_ANALOG2 > +#define PSXPAD_ENABLE_FF > + > +enum { > + PSXPAD_SPI_SPEED_125KHZ = 0, > + PSXPAD_SPI_SPEED_250KHZ, > + PSXPAD_SPI_SPEED_500KHZ, > + PSXPAD_SPI_SPEED_UNKNOWN > +}; > + > +#define PSXPAD_DEFAULT_SPI_DELAY 100 > +#define PSXPAD_DEFAULT_SPI_SPEED PSXPAD_SPI_SPEED_125KHZ > +#define PSXPAD_DEFAULT_INTERVAL16 > +#define PSXPAD_DEFAULT_INTERVAL_MIN8 > +#define PSXPAD_DEFAULT_INTERVAL_MAX32 > +#define PSXPAD_DEFAULT_ADMODE true > +#define PSXPAD_DEFAULT_INPUT_PHYSIZE 32 > + > +#define REVERSE_BIT(x) x) & 0x80) >> 7) | (((x) & 0x40) >> 5) | (((x) & > 0x20) >> 3) | (((x) & 0x10) >> 1) | (((x) & 0x08) << 1) | (((x) & 0x04) << 3) > | (((x) & 0x02) << 5) | (((x) & 0x01) << 7)) > + > +enum { > + PSXPAD_KEYSTATE_TYPE_DIGITAL = 0, > + PSXPAD_KEYSTATE_TYPE_ANALOG1, > +#ifdef PSXPAD_ENABLE_ANALOG2 > + PSXPAD_KEYSTATE_TYPE_ANALOG2, > +#endif /* PSXPAD_ENABLE_ANALOG2 */ > + PSXPAD_KEYSTATE_TYPE_UNKNOWN > +}; > + > +#ifdef PSXPAD_ENABLE_ANALOG2 > +static const u8 PSX_CMD_INIT_PRESSURE[]= {0x01, 0x40, 0x00, 0x00, > 0x02, 0x00, 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_ALL_PRESSURE[] = {0x01, 0x4F, 0x00, 0xFF, 0xFF, > 0x03, 0x00, 0x00, 0x00}; > +#endif /* PSXPAD_ENABLE_ANALOG2 */ > +static const u8 PSX_CMD_POLL[] = {0x01, 0x42, 0x00, 0x00, 0x00, > 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_ENTER_CFG[]= {0x01, 0x43, 0x00, 0x01, 0x00, > 0x00, 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_EXIT_CFG[] = {0x01, 0x43, 0x00, 0x00, 0x5A, > 0x5A, 0x5A, 0x5A, 0x5A}; > +static const u8 PSX_CMD_ENABLE_MOTOR[] = {0x01, 0x4D, 0x00, 0xFF, 0xFF, > 0xFF, 0xFF, 0xFF, 0xFF}; > +static const u8 PSX_CMD_AD_MODE[] = {0x01, 0x44, 0x00, 0x01, 0x00, > 0x00, 0x00, 0x00, 0x00}; > + > +struct psxpad_keystate { > + int type; > + /* PSXPAD_KEYSTATE_TYPE_DIGITAL */ > + bool select; > + bool start; > + bool up; > + bool right; > + bool down; > + bool left; > + bool l2; > + bool r2; > + bool l1; > + bool r1; > + bool triangle; > + bool circle; > + bool cross; > + bool square; > + /* PSXPAD_KEYSTATE_TYPE_ANALOG1 */ > + u8 l3; > + u8 r3; > + u8 lx; > + u8 ly; > + u8 rx; > + u8 ry; > +#ifdef
[RE][PATCH] drivers: input: joystick: Add PSX(Play Staion 1/2) pad with SPI driver Add PSX(Play Staion 1/2) pad with SPI driver. Pads can be connected directry SPI bus.
To Linux kernel input driver mainteners I mailed to mainteners a week ago. Please can anyone answer? Regard. = AZO 2017-04-14 13:28 GMT+09:00 AZO : > --- > drivers/input/joystick/Kconfig | 11 +- > drivers/input/joystick/Makefile | 1 + > drivers/input/joystick/psxpad-spi.c | 679 > > 3 files changed, 690 insertions(+), 1 deletion(-) > create mode 100644 drivers/input/joystick/psxpad-spi.c > > diff --git a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig > index 4215b53..6e38a74 100644 > --- a/drivers/input/joystick/Kconfig > +++ b/drivers/input/joystick/Kconfig > @@ -330,4 +330,13 @@ config JOYSTICK_MAPLE > To compile this as a module choose M here: the module will be called > maplecontrol. > > -endif > +config JOYSTICK_PSXPAD_SPI > + tristate "PSX(Play Station 1/2) pad with SPI Bus Driver" > + depends on INPUT_POLLDEV && SPI > + help > + Say Y here if you connect PSX(PS1/2) pad with SPI Interface. > + > + To compile this driver as a module, choose M here: the > + module will be called psxpad-spi. > + > +endifendif > diff --git a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile > index 92dc0de..2b71848 100644 > --- a/drivers/input/joystick/Makefile > +++ b/drivers/input/joystick/Makefile > @@ -32,4 +32,5 @@ obj-$(CONFIG_JOYSTICK_WARRIOR)+= warrior.o > obj-$(CONFIG_JOYSTICK_XPAD)+= xpad.o > obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o > obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o > +obj-$(CONFIG_JOYSTICK_PSXPAD_SPI) += psxpad-spi.o > > diff --git a/drivers/input/joystick/psxpad-spi.c > b/drivers/input/joystick/psxpad-spi.c > new file mode 100644 > index 000..c5b497b > --- /dev/null > +++ b/drivers/input/joystick/psxpad-spi.c > @@ -0,0 +1,679 @@ > +/* > + * PSX(Play Station 1/2) pad (SPI Interface) > + * > + * Copyright (C) 2017 AZO > + * Licensed under the GPL-2 or later. > + * > + * PSX pad plug (not socket) > + * 123 456 789 > + * (...|...|...) > + * > + * 1: DAT -> MISO (pullup with 1k owm to 3.3V) > + * 2: CMD -> MOSI > + * 3: 9V (for motor, if not use N.C.) > + * 4: GND > + * 5: 3.3V > + * 6: Attention -> CS(SS) > + * 7: SCK -> SCK > + * 8: N.C. > + * 9: ACK -> N.C. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +//#define PSXPAD_ENABLE_ANALOG2 > +#define PSXPAD_ENABLE_FF > + > +enum { > + PSXPAD_SPI_SPEED_125KHZ = 0, > + PSXPAD_SPI_SPEED_250KHZ, > + PSXPAD_SPI_SPEED_500KHZ, > + PSXPAD_SPI_SPEED_UNKNOWN > +}; > + > +#define PSXPAD_DEFAULT_SPI_DELAY 100 > +#define PSXPAD_DEFAULT_SPI_SPEED PSXPAD_SPI_SPEED_125KHZ > +#define PSXPAD_DEFAULT_INTERVAL16 > +#define PSXPAD_DEFAULT_INTERVAL_MIN8 > +#define PSXPAD_DEFAULT_INTERVAL_MAX32 > +#define PSXPAD_DEFAULT_ADMODE true > +#define PSXPAD_DEFAULT_INPUT_PHYSIZE 32 > + > +#define REVERSE_BIT(x) x) & 0x80) >> 7) | (((x) & 0x40) >> 5) | (((x) & > 0x20) >> 3) | (((x) & 0x10) >> 1) | (((x) & 0x08) << 1) | (((x) & 0x04) << 3) > | (((x) & 0x02) << 5) | (((x) & 0x01) << 7)) > + > +enum { > + PSXPAD_KEYSTATE_TYPE_DIGITAL = 0, > + PSXPAD_KEYSTATE_TYPE_ANALOG1, > +#ifdef PSXPAD_ENABLE_ANALOG2 > + PSXPAD_KEYSTATE_TYPE_ANALOG2, > +#endif /* PSXPAD_ENABLE_ANALOG2 */ > + PSXPAD_KEYSTATE_TYPE_UNKNOWN > +}; > + > +#ifdef PSXPAD_ENABLE_ANALOG2 > +static const u8 PSX_CMD_INIT_PRESSURE[]= {0x01, 0x40, 0x00, 0x00, > 0x02, 0x00, 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_ALL_PRESSURE[] = {0x01, 0x4F, 0x00, 0xFF, 0xFF, > 0x03, 0x00, 0x00, 0x00}; > +#endif /* PSXPAD_ENABLE_ANALOG2 */ > +static const u8 PSX_CMD_POLL[] = {0x01, 0x42, 0x00, 0x00, 0x00, > 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_ENTER_CFG[]= {0x01, 0x43, 0x00, 0x01, 0x00, > 0x00, 0x00, 0x00, 0x00}; > +static const u8 PSX_CMD_EXIT_CFG[] = {0x01, 0x43, 0x00, 0x00, 0x5A, > 0x5A, 0x5A, 0x5A, 0x5A}; > +static const u8 PSX_CMD_ENABLE_MOTOR[] = {0x01, 0x4D, 0x00, 0xFF, 0xFF, > 0xFF, 0xFF, 0xFF, 0xFF}; > +static const u8 PSX_CMD_AD_MODE[] = {0x01, 0x44, 0x00, 0x01, 0x00, > 0x00, 0x00, 0x00, 0x00}; > + > +struct psxpad_keystate { > + int type; > + /* PSXPAD_KEYSTATE_TYPE_DIGITAL */ > + bool select; > + bool start; > + bool up; > + bool right; > + bool down; > + bool left; > + bool l2; > + bool r2; > + bool l1; > + bool r1; > + bool triangle; > + bool circle; > + bool cross; > + bool square; > + /* PSXPAD_KEYSTATE_TYPE_ANALOG1 */ > + u8 l3; > + u8 r3; > + u8 lx; > + u8 ly; > + u8 rx; > + u8 ry; > +#ifdef PSXPAD_ENABLE_ANALOG2 > + /* PSXPAD_KEYSTATE_TYPE_ANALOG2 */ > + u8