From: Eric Piel <Eric.Piel@tremplin-utc.net>
To: Vojtech Pavlik <vojtech@suse.cz>, linux-kernel@vger.kernel.org
Cc: decklin@red-bean.com, Peter Nelson <rufus-kernel@hackish.org>
Subject: [PATCH] Hotplug support for several PSX controlers
Date: Sun, 12 Dec 2004 21:24:53 +0100 [thread overview]
Message-ID: <41BCA915.3030407@tremplin-utc.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 1039 bytes --]
Hello,
Since 2.6.9, several PSX controlers in the same time can be supported.
However, because of a bug, if not all the PSX controlers are pluged in
then nothing works. Typically, you load gamecon with options saying that
you have two PSX adapter ports and then you plug and unplug has many
controllers has you want. There is a bug which prevent keypress to be
detected when not all the controllers connected.
The problem was that when a port didn't have a controler pluged the
packet length to receive was read as very big, leading to a kind of
buffer overflow. This patch checks the packet length and if it is bigger
than the theoritical possible it considers that there is no controller
pluged on this port.
It probably works on a vanilla 2.6.10-rc3 but I highly recommand to use
the Vojtech's tree which contains an important fix about PSX DDR (cf
http://marc.theaimsgroup.com/?l=linux-kernel&m=110118014804716&w=2).
I've heard that Linus wants 2.6.10 ready for Christmas, this patch
should definitetly helps ;-)
Eric
[-- Attachment #2: gamecon-psx-hotplug-clamp-length.patch --]
[-- Type: text/x-patch, Size: 1549 bytes --]
--- linux-2.6.10.orig/drivers/input/joystick/gamecon.c 2004-10-20 21:25:06.000000000 +0200
+++ linux-2.6.10-rc3/drivers/input/joystick/gamecon.c 2004-12-12 14:58:35.000000000 +0100
@@ -241,7 +241,7 @@ static void gc_multi_read_packet(struct
#define GC_PSX_SELECT 0x02 /* Pin 3 */
#define GC_PSX_ID(x) ((x) >> 4) /* High nibble is device type */
-#define GC_PSX_LEN(x) ((x) & 0xf) /* Low nibble is length in words */
+#define GC_PSX_LEN(x) (((x) & 0xf) << 1) /* Low nibble is length in words */
static int gc_psx_delay = GC_PSX_DELAY;
module_param_named(psx_delay, gc_psx_delay, uint, 0);
@@ -259,7 +259,7 @@ static short gc_psx_ddr_btn[] = { BTN_0,
* the psx pad.
*/
-static void gc_psx_command(struct gc *gc, int b, unsigned char data[GC_PSX_LENGTH])
+static void gc_psx_command(struct gc *gc, int b, unsigned char data[5])
{
int i, j, cmd, read;
for (i = 0; i < 5; i++)
@@ -302,10 +302,12 @@ static void gc_psx_read_packet(struct gc
for (i =0; i < 5; i++) /* Find the longest pad */
if((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) &&
- (GC_PSX_LEN(id[i]) > max_len))
+ (GC_PSX_LEN(id[i]) > max_len) &&
+ /* Too long length is a sign that no joystick is present */
+ (GC_PSX_LEN(id[i]) <= GC_PSX_LENGTH))
max_len = GC_PSX_LEN(id[i]);
- for (i = 0; i < max_len * 2; i++) { /* Read in all the data */
+ for (i = 0; i < max_len; i++) { /* Read in all the data */
gc_psx_command(gc, 0, data2);
for (j = 0; j < 5; j++)
data[j][i] = data2[j];
next reply other threads:[~2004-12-12 20:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-12 20:24 Eric Piel [this message]
2004-12-12 21:12 ` [PATCH] Hotplug support for several PSX controlers Peter Nelson
2004-12-12 21:54 ` Eric Piel
2004-12-14 1:30 ` Peter Nelson
2004-12-15 9:30 ` Eric Piel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41BCA915.3030407@tremplin-utc.net \
--to=eric.piel@tremplin-utc.net \
--cc=decklin@red-bean.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rufus-kernel@hackish.org \
--cc=vojtech@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox