apple-gmux: Fixes related to 'Support for new hardware'
v2 cover apple-gmux: Fixes related to 'Support for new hardware'
Hello,
it follows a refined version where thanks to Seth and his extensive x86 assembly knowledge my initial assumption about how Apple does byte writes could be falsified. It appears that byte writes only failed because the index protocol was not correctly followed in the read functions.
Cheers,
Bernhard
PATCH v2 1/2 apple-gmux: Fix index read functions
From: Bernhard Froemel <[email protected]>
Study of Apple's binary driver revealed that the GMUX_READ_PORT should be written between calls to gmux_index_wait_ready and gmux_index_wait_complete (i.e., the new index protocol must be followed). If this is not done correctly, the indexed
gmux device only partially accepts writes which lead to problems concerning GPU switching. Special thanks to Seth Forshee who helped greatly with identifying unnecessary changes.
--- drivers/platform/x86/apple-gmux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/platform/x86/apple-gmux.c +4 -2
@@ -142,8 +142,9 @@ static u8 gmux_index_read8(struct apple_gmux_data *gmux_data, int port)u8 val;mutex_lock (&gmux_data->index_lock); -outb ((port &0xff ), gmux_data->iostart +GMUX_PORT_READ );gmux_index_wait_ready (gmux_data); +outb ((port &0xff ), gmux_data->iostart +GMUX_PORT_READ ); +gmux_index_wait_complete (gmux_data); val =inb (gmux_data->iostart +GMUX_PORT_VALUE );mutex_unlock (&gmux_data->index_lock);
@@ -166,8 +167,9 @@ static u32 gmux_index_read32(struct apple_gmux_data *gmux_data, int port)u32 val;mutex_lock (&gmux_data->index_lock); -outb ((port &0xff ), gmux_data->iostart +GMUX_PORT_READ );gmux_index_wait_ready (gmux_data); +outb ((port &0xff ), gmux_data->iostart +GMUX_PORT_READ ); +gmux_index_wait_complete (gmux_data); val =inl (gmux_data->iostart +GMUX_PORT_VALUE );mutex_unlock (&gmux_data->index_lock);
Signature · 1 line
1.7.9.5
PATCH v2 2/2 apple-gmux: Obtain version info from indexed gmux
From: Bernhard Froemel <[email protected]>
This patch extracts and displays version information from the indexed gmux device as it is also done for the classic gmux device.
--- drivers/platform/x86/apple-gmux.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/platform/x86/apple-gmux.c +8 -4
@@ -463,18 +463,22 @@ static int __devinit gmux_probe(struct pnp_dev *pnp, ver_release =gmux_read8 (gmux_data,GMUX_PORT_VERSION_RELEASE );if (ver_major ==0xff && ver_minor ==0xff && ver_release ==0xff ) {if (gmux_is_indexed (gmux_data)) { +u32 version;mutex_init (&gmux_data->index_lock); gmux_data->indexed = true; + version =gmux_read32 (gmux_data, +GMUX_PORT_VERSION_MAJOR ); + ver_major = (version >>24 ) &0xff ; + ver_minor = (version >>16 ) &0xff ; + ver_release = (version >>8 ) &0xff ; }else {pr_info ("gmux device not present\n" ); ret = -ENODEV ; goto err_release; } -pr_info ("Found indexed gmux\n" ); - }else { -pr_info ("Found gmux version %d.%d.%d\n" , ver_major, ver_minor, - ver_release); } +pr_info ("Found gmux version %d.%d.%d [%s]\n" , ver_major, ver_minor, + ver_release, (gmux_data->indexed ?"indexed" :"classic" ));memset (&props,0 ,sizeof (props)); props.type =BACKLIGHT_PLATFORM ;
Signature · 1 line
1.7.9.5
Re: [PATCH v2 2/2] apple-gmux: Obtain version info from indexed gmux
Quoted 6 lines · Bernhard Froemel
From: Bernhard Froemel <[email protected]>
This patch extracts and displays version information from the indexed gmux device as it is also done for the classic gmux device.
Signed-off-by Bernhard Froemel <[email protected]>
Re: [PATCH v2 1/2] apple-gmux: Fix index read functions
In reply to Bernhard FroemelQuoted 10 lines · Bernhard Froemel
From: Bernhard Froemel <[email protected]>
Study of Apple's binary driver revealed that the
GMUX_READ_PORTshould be written between calls togmux_index_wait_readyandgmux_index_wait_complete(i.e., the new index protocol must be followed). If this is not done correctly, the indexed
gmux device only partially accepts writes which lead to problems concerning GPU switching. Special thanks to Seth Forshee who helped greatly with identifying unnecessary changes.
Quoted 2 lines
Signed-off-by Bernhard Froemel <[email protected]>---
Hi Bernhard,
thanks for your patch, this works splendidly; I can resume and select different screen resolutions using xrandr.
Henrik
Re: [PATCH v2 1/2] apple-gmux: Fix index read functions
In reply to Bernhard FroemelQuoted 11 lines · Bernhard Froemel
From: Bernhard Froemel <[email protected]>
Study of Apple's binary driver revealed that the
GMUX_READ_PORTshould be written between calls togmux_index_wait_readyandgmux_index_wait_complete(i.e., the new index protocol must be followed). If this is not done correctly, the indexed
gmux device only partially accepts writes which lead to problems concerning GPU switching. Special thanks to Seth Forshee who helped greatly with identifying unnecessary changes.Signed-off-by Bernhard Froemel <[email protected]>
This does better match what Apple's driver does. Thanks Bernhard.