-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement stub version of the Wii AV Encoder #10863
base: master
Are you sure you want to change the base?
Conversation
The i2c bus addressing is 7 bits (or 10 bits for extended addressing, but that doesn't seem to be needed here), with the last bit of that byte determining if it's a read or write operation. There's a pretty good explanation of the i2c bus here: https://www.robot-electronics.co.uk/i2c-tutorial So address would be: ((byte >> 1) & 0x7F) |
Yes, I have that implemented already; it detects read operations and does not acknowledge them: dolphin/Source/Core/Core/HW/WII_IPC.cpp Lines 360 to 384 in b551c8b
I just haven't implemented sending back data if a read operation is performed, as no games I have seem to use it. To clarify, the AV encoder is located at I2C address 0x70 (0b1110000) which is apparently used for "AV colour space converters" typically, which does mean that it's written using the byte |
Although current_address is just assigned a byte directly from the i2c stream so it's missing the drop of the read/write bit? |
Since there's only one device, I never actually store the i2c address; it's only checked if it is 0x70 ( (Though now I'm not sure how a read would even work, as you would need to write |
Now I understand, I expected current_address to be the address of the currently addressed device. I suspect at this time it's no use to divide the struct up between bus and device, but perhaps a comment about what is bus state and what is device state would help clarify? For reads to work the chip's registers would need to be somewhat properly emulated (default register states) and knowing what writes would end up looking like (as sometimes software is lazy and writes RO bits), and carry the entire address data around in structs / arrays. Some devices (unfortunately, mostly video decoders) are paged, so the address space then is the number of pages * 256. |
I think the device itself has a 256-byte address space without paging (it might be a 128-byte address space even, as the highest known register is 0x7D). All listed registers are marked writable (though Wiibrew doesn't say whether they're all readable - I'm not sure if that's a case of reading not having been tested, or if they read back as 0 or something. After looking more closely at the symbol map, a (The article you linked also explained how reads work: you send start, then the 7-bit address and a 0 bit (for write), then the internal address, then another start, then the 7-bit address and a 1-bit (for read), then start reading, then send stop. The second start is something I wasn't aware of.) |
Commented on the issue ticket but yes, the logging does show the gamma values changing when changed in game:
|
Source/Core/Core/HW/WII_IPC.cpp
Outdated
else if (address == 0x71) | ||
return "Audio stereo output control - right volume"; | ||
else if (address == 0x72) | ||
return "Audio stereo output control - right volume"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this was meant to be the left channel volume, otherwise it seems really weird that the right channel appears twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, probably it should be left, though the wiki is a bit ambiguous: https://wiibrew.org/wiki/Hardware/AV_Encoder#Registers_71h_.26_72h
dda7279
to
445db71
Compare
I still need to document this; GPIOs are wierd with their tristate behavior
The wrong value is read, but this is the correct structure, at least...
Currently this is a copy of the Wii Remote I2CBus, and is unused. That will change in later commits.
This reverts commit cf90785d59af9a295825573be7813a06b7766666.
This PR implements a stub version of the audio/video encoder (AVE-RVL) found on the Wii. This is accessed via I²C using two GPIO pins, which involves some awkward bitbanging on the PPC side, and is even more awkward for us. All I've done is implement this I²C interface and respond to it appropriately, specifically only for writes to the address of the AV encoder (reads are unhandled, and games don't seem to use them, though symbol maps mention
__VIGetVenderID
,VIGetCGMS
, andVIGetWSS
so this might be an issue). (Note that the way I²C acknowledges a byte is by holding the data line low, and since the previous implementation never set AVE_SDA for the input it always was acknowledged; now we don't acknowledge it in some cases.)The logging occurs under
WII_IPC
since that's where the GPIOs are handled currently (and very little else is logged there).This is mainly intended to help with debugging gamma issues (e.g. 12974).