[haiku-development] Re: S3 Virge video driver

Philippe Houdoin wrote:
Quoting Gerald Zajac <zajacg@xxxxxxxxxxxxx>:

Since much of the code for the S3 Virge video driver is similar to the
Savage video driver, I have decided to implement a driver for the Virge
& Trio 3D video chips.  However, I'm having a problem enabling MMIO.  It
appears that ISA I/O is needed to enable the MMIO.  I have looked at
Syllable's Virge driver source file, and it has a "Be Sample Code"
license;  however, I have not been able to find the original BeOS sample
code on the web.  Does anyone have a copy of this code or know where I
can obtain a copy?  It is not in the R5 sample code, and I believe that
it is probably pre-R4.

It's from R3.
You will find its source code there:
http://public.www.planetmirror.com/pub/beos/samples/drivers/obsolete/VideoDriverKit.zip

Beware, this driver code was following the old app_server's graphics API which
was fully user-land based, the kernel exposing ISA and PCI functions at this
time.
With the R4 and sooner kernel + userland add-ons graphics API, it wont works
anymore...

If I interpret the above correctly, the code to perform this action should be in the driver instead of the accelerant. In the driver there currently is code to map the MMIO register area by calling map_physical_memory(). After this code, I'm planning to insert the code to enable MMIO.
Since Syllable has different functions for ISA I/O, I want to see what
functions were used to enable the MMIO under BeOS and how they were used.

As Jerome already said, you'll need to setup the device PCI configuration to
enable MMIO.
Otherwise, for old ISA I/O, just use the ISA module:

Since these video cards are either AGP or PCI cards, should I be using PCI I/O instead of ISA I/O or will either accomplish the same thing since I'm only trying to read/write some values in the MMIO area?

#include <ISA.h>

isa_module_info *isa = NULL;

if (get_module(B_ISA_MODULE_NAME, (module_info *) &isa) != B_OK)
  /* error, no ISA module available */
  return B_ERROR;

Then, to do I/O:

value = isa->read_io_8/16/32(ISA_PORT_ADDRESS);
isa->write_io_8/16/32(ISA_PORT_ADDRESS, value);

Since I'm trying to access values in the MMIO area, is the port address the mapped address of the MMIO area plus the offset of the value in the MMIO area?

Last but not least, don't forget to release ISA module when not used anymore:

put_module(B_ISA_MODULE_NAME);

Hope this help.
Yes, Thanks for the info. I did not know how to setup to use the read_io/write_io functions.

Thanks,
Gerald

Other related posts: