Rockbox Technical Forums

Third Party => Unsupported Builds => Topic started by: stealiesubie on January 17, 2015, 06:56:20 AM

Title: USB charge only mode
Post by: stealiesubie on January 17, 2015, 06:56:20 AM
Hey all,
I'm looking for some help. I'm trying to get this feature into a build for my 7th gen iPod:
http://www.rockbox.org/tracker/10198
It's throwing errors when compiling. I've asked others for help and they have the same errors.
As I explained to someone else:

 My problem is this: I upgraded the head unit in my car to an android based unit. The factory aux port doesn't work. It has an iPod control, but my Rockbox'd unit doesn't work with it. I did figure out that if I force the iPod into charge only mode by holding down menu when I plug it into the head unit, audio will play. I have to control it directly from the iPod, but it will play. The problem is every time the iPod starts, it defaults to connect mode and not charge mode. It's a pain to have to unplug and replug holding the menu button every time I start my car. With the oem unit, I put the iPod in car adapter mode and it worked great through the aux input. The new unit also has a sub port, but when I plug into that it causes the head unit to crash. I'm just dying to get my music back so it starts and stops automatically with my car. Other than that, the Android head unit is sick. Any input you have is greatly appreciated! I'm using a 7th gen iPod with a 256gb SD card in it.
Title: Re: USB charge only mode
Post by: saratoga on January 17, 2015, 03:08:03 PM
That patch is almost 6 years old.  Its not going to apply.  You'll have to go through it line by line and add the code manually to each file.
Title: Re: USB charge only mode
Post by: stealiesubie on January 17, 2015, 04:02:15 PM
I'm just not that experienced. If anyone can help, I'd be most grateful.
Title: Re: USB charge only mode
Post by: joesomebody on February 04, 2015, 11:33:57 PM
I'm just not that experienced. If anyone can help, I'd be most grateful.

Isn't there only an option to enable or disable USB charging right now? I can't recall.
Title: Re: USB charge only mode
Post by: Dr Matt on October 17, 2015, 11:22:12 PM
Sorry to necro this thread but I would really appreciate this feature too. I have Rockbox successfully running on my iPod Gen 7 but every time I plug it into my car's iPod adaptor kit (http://gromaudio.com/ (http://gromaudio.com/)), Rockbox goes into USB file transfer mode and I lose all functionality. Just as the OP points out, I can over-ride this by pushing a button while connecting the device but having to do this every time I start the car is pretty frustrating.

An option to make charging mode the default would be most welcome. Actually, simply reversing the default behaviour so that I have to push a button to enter file transfer mode rather than charging mode would be perfectly adequate. Has anyone been able to accomplish this with a recent Rockbox build?

I think the functionality that I'm after is associated with this piece of code from firmware/usb.c:

Code: [Select]
/* Power (charging-only) button */
static inline bool usb_power_button(void)
{
#ifdef HAVE_USB_POWER
    return (button_status() & ~USBPOWER_BTN_IGNORE);
#else
    return false;
#endif
}

I've been trying to get my head around the syntax but its a pretty steep learning curve. Maybe the solution is obvious to one of the super users. Any advice/comments are very welcome.
Title: Re: USB charge only mode
Post by: while(E) on April 18, 2019, 12:52:59 PM
Sorry to necro this after YEARS... but this feature still doesn't freaking exist... and I was looking for this same functionality, and this post helped remind me I'm a damn software dev and I can accomplish this myself....

So for some background, this is a bitwise operation. You have a bitmask (USBPOWER_BTN_IGNORE) that simply holds the mas of the buttons to ignore in a binary format (0000 1100). Therefore you would ignore whatever buttons that set those two bits when pressed. The (& ~) operators simply mean, (~) get the oppposite (1111 0011), thus only listen for buttons we DONT want to ignore, and the (&) means let's take the returned bit status from button_status() and make sure one of the buttons matches what we're listening to with the inverse of USBPOWER_BTN_IGNORE.  To get more in-depth just look up bitmasks and bitwise operators. They're super useful and simple to understand.

That being said this line is different in current builds, it's now:
Code: [Select]
if (detect)
   detect = button_status() & ~USBPOWER_BTN_IGNORE;

which you can simply change to:
Code: [Select]
if (detect)
   detect = !(button_status() & ~USBPOWER_BTN_IGNORE);

I just compiled, and it worked perfectly. Plug in USB, nothing happens except charging. Plug in USB while holding button, and it goes into USB mode. Hope it helps somone :)