path: root/firmware/target/mips/ingenic_jz47xx
AgeCommit message (Collapse)AuthorFilesLines
2020-08-26xduoox3: Update battery discharge curve and runtime estimatesSolomon Peachy1-4/+4
(Brand new unit lasted one minute shy of 12 hours!) Change-Id: I0330f43065412d432a45b555bb310f943eb526e7
2020-08-25jz4740: SD clock sequencing changes.Solomon Peachy1-17/+13
* Don't stop clock before switching speeds * Don't stop clock prior to transactions * Stop clock at the end of transactions Will result in slightly better performance and some power saving when we're not actively using the SD peripheral. Change-Id: I1c82476cad97137b1469900645ecf7bb0887119a
2020-08-25jz4760: SD driver enhancements:Solomon Peachy1-41/+90
* Check to see if clock is [not] running prior to [en|dis]abling it * Stop clock _prior_ to resetting controller * Stop clock after transaction is completed, not before initiating it * Use controller's low power mode (disables clocks when idle) * Fix, and enable, interrupt-driven DMA transfers * Fixes for full interrupt-driven operation (WIP, still broken) Change-Id: I723ffa6450fc85f97898c8a8b3e538ae31c4858e
2020-08-25jz4740: Fix potential deadlock in SD init code.Solomon Peachy1-7/+8
There's a code path that calls sd_init_device() while we hold sd_mtx, but sd_init_device() tries to obtain the mutex while doing its work. Change-Id: I882c595e9e7cd2224b1db0d413925668628476e9
2020-08-25jz4760: Give each SD interface its own DMA channel, semaphore, and mutexSolomon Peachy3-91/+175
* Allows both SD interfaces to have requests in flight simultaneously * Fixed a deadlock in the hotswap code * Ensure TX DMA is idle before initiating a request (bug due to a typo) Change-Id: I988fa29df5f8e41fc6bbdcc517db89842003b34d
2020-08-12jz4760: Use HW timer for more a more accurate udelay()Solomon Peachy1-0/+29
(More specifically, use the SoC's "OS Timer", slaved to the main XTAL so it doesn't matter how the main CPU is clocked) Change-Id: I799561ac823ff7f659a05144cf03b6a13d57ea7b
2020-08-08jz4760: Move 11/22/44/88KHz back onto the PLLSolomon Peachy1-8/+16
PLL1 clock for those frequencies has been dropped from 508 to 169.5 MHz, so it's still a respectable reduction. (I'm not sure how/why it ever worked with the XTAL source, but it did, and was off by an audible amount) Change-Id: I614d87e7dfdfe9210702b9c646d3863c06d6780b
2020-08-07jz4760: Major clocking improvements for audio PLLSolomon Peachy1-37/+55
* for <= 48KHz, BCLK must be 256*freq (ie bdiv = 4) * for <= 96KHz, BCLK must be 128*freq (ie bdiv = 2) * for 11/22/44/88 KHz, disable PLL1 and run off XTAL * cut PLL1 with 12/24/48/98 KHz audio from 516->86MHz * cut PLL1 with 8/16/32/64 KHz audio from 426->106.5MHz This should result in significant power savings for common 44.1KHz audio playback, and pretty good savings for everything else. As an added bonus: * enable de-emphasis filters at 32, 44.1, and 48 KHz Change-Id: Ie59067cd46c47e62abf4a32c53519efad104d6c8
2020-08-07jz4760: Support dynamic reclocking!Solomon Peachy2-23/+54
default/low speed is 192 MHz, Max is 576 Downclock PCLK/MCLK/etc to 96MHz to save a bit of juice Honestly the high speed could be dialed down to, eg 384 as this thing is so bloody fast.. Change-Id: Ie65597c74290f1603e65f69dae8e75b59c8ba0b4
2020-08-07jz4760: Fixes in PLL calculation and reportingSolomon Peachy3-14/+12
Change-Id: I890c661fbff549de5a224d90e3fbda34c71b3a7e
2020-08-07xduoox3: Set PLL0 to 480MHz, not 492.Solomon Peachy1-1/+1
PLL0 Needs to be a multiple of 48MHz for sane USB operation! (Indeed, "typical" clock for this part is 528, but that seems a waste of power) Also fixes a minor bugaboo in the jz4670 usb divisor calculation that won't matter until we enable reclocking Change-Id: I40b1fd1ae48871e50885981ccc8b01feb711b9a5
2020-08-07jz4760: Don't enable PLL1 until we need audio.Solomon Peachy2-29/+48
Change-Id: I6320ee9ac809da93c80e571d45f01e22c5bd1c40
2020-08-07jz7460: debugging improvementsSolomon Peachy1-15/+14
Change-Id: Ie03609ebe8bff51eed26e3781fe2b8663cc49e3a
2020-07-24[4/4] Remove HAVE_LCD_BITMAP, as it's now the only choice.Solomon Peachy1-2/+1
Note: I left behind lcd_bitmap in features.txt, because removing it would require considerable work in the manual and the translations. Change-Id: Ia8ca7761f610d9332a0d22a7d189775fb15ec88a
2020-07-15mips: Adjust stack sizesSolomon Peachy2-4/+4
Main/IRQ from: 7.5/0.75 to: 7.25/1.0 With the reduction of the opus codec stack usage, giving the IRQ stack some additional breathing room is now possible. Change-Id: Id0cd3747fcaab70e2360667ac8c1a97ba7234ccf
2019-07-29XduooX3: Uncomment code that prevented hotswap from working.Solomon Peachy1-2/+2
Change-Id: I5efec00e60aacf05166407ad43b9d63340e18967
2019-06-02jz7460: Disable IRQ-driven DMA transfers.Solomon Peachy1-1/+1
This greatly increases the stability of SD card write operations. (I suspect the underlying problem is not IRQ operation itself, instead being exacerbated by it..) Change-Id: Ia00f0656abd4b3cb0b1b5fc9db7c1b6a02847956
2019-01-04Add HAVE_LINEOUT_DETECTION and associated logicSolomon Peachy2-7/+36
This allows targets to automatically switch audio settings when the line out is plugged/unplugged. Only hooked up on the xDuoo X3, but there are other potential users. Change-Id: Ic46a329bc955cca2e2ad0335ca16295eab24ad59
2019-01-02mips: Adjust main & irq stack sizes to fit in IRAM on all targetsSolomon Peachy2-4/+4
New amounts: 7.50K main stack 0.75K irq stack Prior values of 8K+1K overflowed IRAM by ~660 bytes on Onda 7x7 targets, but worked on the xDuoo X3. (The discrepancy is due to the Onda targets having more LCD code shoved into IRAM.) Change-Id: I16fcfae3c5f3e36db688dfa9167b620584e79df8
2019-01-02mips: Use a separate IRQ stack & optimize IRQ handling a littleSolomon Peachy3-38/+60
Should prevent the IRQ-related stack overflows seen on MIPS targets. Change-Id: I447336ef3fe37e11b3276a78ba220ce64c2f87f5
2019-01-02Fix Xduoo X3 bootloader build, and silence all warnings.Solomon Peachy2-1/+106
Also enable USB bootloader mode Change-Id: I73224c2e694b9941993c89a114b48d2a907e0dfb
2018-10-09mips: fix some compile warnings.Solomon Peachy4-5/+5
Change-Id: Ia5e83702313c1c184480290d3b0e6a66f01b7277
2018-10-09mips: jz4740: JZ4740 does not have a MSC clock source select.Solomon Peachy1-1/+1
Change-Id: Ic2af37d92bcb8b6b35684f113eb8e392fc2eb609
2018-09-20jz4760: Lots of stability fixes to the USB driver.Solomon Peachy1-84/+292
It actually works for transferring data now! Igor Poretsky gets full credit for this patch. Change-Id: I247c70fdf45e590b4699b9b8668bbdab7bc3ef03
2018-09-20xduoo_x3: Disable keypress IRQ since we poll for keypresses.Solomon Peachy1-4/+7
Change-Id: Ieab5f864751cf798b62c4e89e670acf7ade756ab
2018-09-20jz4760: Enhancements and fixes to SD driver.Solomon Peachy1-279/+239
* Fully Interrupt-driven, with proper task yielding * Much more robust error handling * Eliminate duplicate code * Pile of bugfixes (Much of this adapted from Igor Poretsky's tree) Change-Id: I46006412323cba2088b70094635d62a241be1d7e
2018-09-20jz7460: Silence codec when changing playback frequency/modeSolomon Peachy1-2/+6
Silences some annoying clicks. Change-Id: I3d32d4b33c0ccc61877e10f5af97fe05084d66e5
2018-09-20jz7640: SD driver improvements:Solomon Peachy1-27/+25
* Better multidrive support * Common slot1/slot2 handling code Change-Id: Id0aed90cbba4246fdc71b42e03f016f8060d258a
2018-09-20jz74x0: MSC clock needs to be divided from PLL clock.Solomon Peachy2-2/+7
Change-Id: I0cf2f0d55e0859f896afef289e833935d7c5a599
2018-09-20jz4760: Greatly enhance debug code and silence some compilation warnings.Solomon Peachy4-109/+138
Change-Id: I1746d67c818ad099edea83e6242ffd5c79be0000
2018-07-28Add cleaned-up xDuoo X3 supportSolomon Peachy27-6/+6013
Cleaned up, rebased, and forward-ported from the xvortex fork. (original credit to Change-Id: Ibcc023a0271ea81e901450a88317708c2683236d Signed-off-by: Solomon Peachy <>
2017-10-26Fix a few missed things in 16454efc (and hopefully clear the red).Michael Sevakis1-4/+0
Change-Id: I2ce88e4c41e6e08efbfbdf261122318dfb0f8b0f
2017-10-26Unify storage threads into oneMichael Sevakis1-72/+24
* Editing a bunch of drivers' thread routines in order to implement a new feature is tedious. * No matter the number of storage drivers, they share one thread. No extra threads needed for CONFIG_STORAGE_MULTI. * Each has an event callback called by the storage thread. * A default callback is provided to fake sleeping in order to trigger idle callbacks. It could also do other default processing. Changes to it will be part of driver code without editing each one. * Drivers may sleep and wake as they please as long as they give a low pulse on their storage bit to ask to go into sleep mode. Idle callback is called on its behalf and driver immediately put into sleep mode. * Drivers may indicate they are to continue receiving events in USB mode, otherwise they receve nothing until disconnect (they do receive SYS_USB_DISCONNECTED no matter what). * Rework a few things to keep the callback implementation sane and maintainable. ata.c was dreadful with all those bools; make it a state machine and easier to follow. Remove last_user_activity; it has no purpose that isn't served by keeping the disk active through last_disk_activity instead. * Even-out stack sizes partly because of a lack of a decent place to define them by driver or SoC or whatever; it doesn't seem too critical to do that anyway. Many are simply too large while at least one isn't really adequate. They may be individually overridden if necessary (figure out where). The thread uses the greatest size demanded. Newer file code is much more frugal with stack space. I barely see use crack 50% after idle callbacks (usually mid-40s). Card insert/eject doesn't demand much. * No forcing of idle callbacks. If it isn't necessary for one or more non-disk storage types, it really isn't any more necessary for disk storage. Besides, it makes the whole thing easier to implement. Change-Id: Id30c284d82a8af66e47f2cfe104c52cbd8aa7215
2015-01-12Fix red/yellowMarcin Bukat1-1/+1
Change-Id: Ie01251af2cd843979b5fdefcfa541ba377d13bd7
2015-01-12Get rid of stupid _backlight_* function namesMarcin Bukat5-19/+19
_remote_backlight_* and _buttonlight_* are cleaned as well Change-Id: I73653752831bbe170c26ba95d3bc04c2e3a5cf30
2014-08-30Rewrite filesystem code (WIP)Michael Sevakis1-18/+11
This patch redoes the filesystem code from the FAT driver up to the clipboard code in onplay.c. Not every aspect of this is finished therefore it is still "WIP". I don't wish to do too much at once (haha!). What is left to do is get dircache back in the sim and find an implementation for the dircache indicies in the tagcache and playlist code or do something else that has the same benefit. Leaving these out for now does not make anything unusable. All the basics are done. Phone app code should probably get vetted (and app path handling just plain rewritten as environment expansions); the SDL app and Android run well. Main things addressed: 1) Thread safety: There is none right now in the trunk code. Most of what currently works is luck when multiple threads are involved or multiple descriptors to the same file are open. 2) POSIX compliance: Many of the functions behave nothing like their counterparts on a host system. This leads to inconsistent code or very different behavior from native to hosted. One huge offender was rename(). Going point by point would fill a book. 3) Actual running RAM usage: Many targets will use less RAM and less stack space (some more RAM because I upped the number of cache buffers for large memory). There's very little memory lying fallow in rarely-used areas (see 'Key core changes' below). Also, all targets may open the same number of directory streams whereas before those with less than 8MB RAM were limited to 8, not 12 implying those targets will save slightly less. 4) Performance: The test_disk plugin shows markedly improved performance, particularly in the area of (uncached) directory scanning, due partly to more optimal directory reading and to a better sector cache algorithm. Uncached times tend to be better while there is a bit of a slowdown in dircache due to it being a bit heavier of an implementation. It's not noticeable by a human as far as I can say. Key core changes: 1) Files and directories share core code and data structures. 2) The filesystem code knows which descriptors refer to same file. This ensures that changes from one stream are appropriately reflected in every open descriptor for that file (fileobj_mgr.c). 3) File and directory cache buffers are borrowed from the main sector cache. This means that when they are not in use by a file, they are not wasted, but used for the cache. Most of the time, only a few of them are needed. It also means that adding more file and directory handles is less expensive. All one must do in ensure a large enough cache to borrow from. 4) Relative path components are supported and the namespace is unified. It does not support full relative paths to an implied current directory; what is does support is use of "." and "..". Adding the former would not be very difficult. The namespace is unified in the sense that volumes may be specified several times along with relative parts, e.g.: "/<0>/foo/../../<1>/bar" :<=> "/<1>/bar". 5) Stack usage is down due to sharing of data, static allocation and less duplication of strings on the stack. This requires more serialization than I would like but since the number of threads is limited to a low number, the tradoff in favor of the stack seems reasonable. 6) Separates and heirarchicalizes (sic) the SIM and APP filesystem code. SIM path and volume handling is just like the target. Some aspects of the APP file code get more straightforward (e.g. no path hashing is needed). Dircache: Deserves its own section. Dircache is new but pays homage to the old. The old one was not compatible and so it, since it got redone, does all the stuff it always should have done such as: 1) It may be update and used at any time during the build process. No longer has one to wait for it to finish building to do basic file management (create, remove, rename, etc.). 2) It does not need to be either fully scanned or completely disabled; it can be incomplete (i.e. overfilled, missing paths), still be of benefit and be correct. 3) Handles mounting and dismounting of individual volumes which means a full rebuild is not needed just because you pop a new SD card in the slot. Now, because it reuses its freed entry data, may rebuild only that volume. 4) Much more fundamental to the file code. When it is built, it is the keeper of the master file list whether enabled or not ("disabled" is just a state of the cache). Its must always to ready to be started and bind all streams opened prior to being enabled. 5) Maintains any short filenames in OEM format which means that it does not need to be rebuilt when changing the default codepage. Miscellaneous Compatibility: 1) Update any other code that would otherwise not work such as the hotswap mounting code in various card drivers. 2) File management: Clipboard needed updating because of the behavioral changes. Still needs a little more work on some finer points. 3) Remove now-obsolete functionality such as the mutex's "no preempt" flag (which was only for the prior FAT driver). 4) struct dirinfo uses time_t rather than raw FAT directory entry time fields. I plan to follow up on genericizing everything there (i.e. no FAT attributes). 5) unicode.c needed some redoing so that the file code does not try try to load codepages during a scan, which is actually a problem with the current code. The default codepage, if any is required, is now kept in RAM separarately (bufalloced) from codepages specified to iso_decode() (which must not be bufalloced because the conversion may be done by playback threads). Brings with it some additional reusable core code: 1) Revised file functions: Reusable code that does things such as safe path concatenation and parsing without buffer limitations or data duplication. Variants that copy or alter the input path may be based off these. To do: 1) Put dircache functionality back in the sim. Treating it internally as a different kind of file system seems the best approach at this time. 2) Restore use of dircache indexes in the playlist and database or something effectively the same. Since the cache doesn't have to be complete in order to be used, not getting a hit on the cache doesn't unambiguously say if the path exists or not. Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8 Reviewed-on: Reviewed-by: Michael Sevakis <> Tested: Michael Sevakis <>
2014-03-04ingenic: crt0.S fixes #3Marcin Bukat1-6/+5
Hopefyly this time is the final one. Change-Id: I386964f407ca98499e9a482507e4d5dfa02ee891
2014-03-04ingenic: fix bugs introduced by 5900bf7Marcin Bukat1-6/+6
I must have been blind and copied some intermediate file instead of final version. No functional change, only fixes. Change-Id: Icaa868225517662c88f8492b1f04808407853361
2014-03-03ingenic: Tweak a few details in crt0.SMarcin Bukat1-13/+14
1) Avoid load/store delay slot by reorganizing instructions in copy loops 2) Fix off-by-one error in cache initialization code. This was harmless as it simply set line0 twice, now it sets every cacheline only once. 3) Fix off-by-word error in .bss clearing loop. The addiu in branch delay slot even if calculated is not seen by the branch instruction itself, so the code did one word too much in clearing. 4) Fix off-by-word error in deadbeefing stack. See above. Change-Id: Iabb09a55979de7aa2e2b9234273683fc7e9762c5
2013-09-05touch devices: Disable touch on softlock.Jean-Louis Biasini1-0/+7
Target that have a touchpad/touchscreen should disable it while being locked (In order to avoid LCD to drain battery power due to "key locked" constant reporting messages. If they a have a keylock button this was already handled at driver level. If not (e.g. fuze+), they will have to implement a switch at driver level that action.c can operate on softlock. This patch does the following for any target having a touchpad or a touchscreen and no HAS_BUTTON_HOLD (ie any softlock target) 1) it implements the code to call button_enable_touch(bool en) in action.c. 2) button_enable_touch is implemented in button.c and call either touchpad_enable or touchscreen_enable 3) those two function are implemented respectively in touchscreen.c and a new touchpad.c file. They provide a generic way to silents touch's device and call a function at driver level where target specific code can be implemented if possible/needed (for power saving for instance). Those function name are touchpad_enable_device and touchscreen_enable_device 4) we implement an empty function at driver level of targets that need it to have them still being able to compiled. Change-Id: I9ead78a25bd33466a8533f5b9f259b395cb5ce49 Reviewed-on: Reviewed-by: Thomas Martitz <> Reviewed-by: Amaury Pouly <>
2013-08-17Cleanup MV/MD macros a little.Michael Sevakis2-5/+5
When using variadic macros there's no need for IF_MD2/IF_MV2 to deal with function parameters. IF_MD/IF_MV are enough. Throw in IF_MD_DRV/ID_MV_VOL that return the parameter if MD/MV, or 0 if not. Change-Id: I7605e6039f3be19cb47110c84dcb3c5516f2c3eb
2013-04-22Do some cleanup, adjustment and a couple fixes to recent sound changes.Michael Sevakis1-3/+3
* SOUND_x enum can be generated by audiohw_settings.h along with settings entries and sound_val2phys. * VOLUME_MIN and VOLUME_MAX are no longer necessary within sound.c. If you need them, they are for target-defined purposes. * Fix up SDL volume implementation in sdl.c. Move sim volume calculation code to pcm-sdl.c. * Min trigger tresholds were based upon VOLUME_MIN for some reason. These setting have nothing to do with playback volume. Since it is no longer present, set these at -89dB which is the minimum peak meter sensitivity setting. * Fix an oversight in wm8758.c. I forgot to add the dB->register conversion to audiohw_set_volume. Change-Id: Ie1df33f1793eee75e6793f16bc7bddd16edb7f75
2013-04-15Still at it for 0c7b787. Might be done now.Michael Sevakis1-1/+1
Change-Id: Idf45731dc6554954747f6036dc6dfcd4b63981a1
2013-04-15Straighten out the mad twisted state of sound.c and related areas.Michael Sevakis1-24/+0
This is going right in since it's long overdue. If anything is goofed, drop me a line or just tweak it yourself if you know what's wrong. :-) Make HW/SW codec interface more uniform when emulating HW functionality on SWCODEC for functions such as "audiohw_set_pitch". The firmware-to- DSP plumbing is in firmware/drivers/audiohw-swcodec.c. "sound_XXX" APIs are all in sound.c with none in DSP code any longer. Reduce number of settings definitions needed by each codec by providing defaults for common ones like balance, channels and SW tone controls. Remove need for separate SIM code and tables and add virtual codec header for hosted targets. Change-Id: I3f23702bca054fc9bda40f49824ce681bb7f777b
2013-04-11Implement universal in-PCM-driver software volume control.Michael Sevakis1-9/+18
Implements double-buffered volume, balance and prescaling control in the main PCM driver when HAVE_SW_VOLUME_CONTROL is defined ensuring that all PCM is volume controlled and level changes are low in latency. Supports -73 to +6 dB using a 15-bit factor so that no large-integer math is needed. Low-level hardware drivers do not have to implement it themselves but parameters can be changed (currently defined in pcm-internal.h) to work best with a particular SoC or to provide different volume ranges. Volume and prescale calls should be made in the codec driver. It should appear as a normal hardware interface. PCM volume calls expect .1 dB units. Change-Id: Idf6316a64ef4fb8abcede10707e1e6c6d01d57db Reviewed-on: Reviewed-by: Michael Sevakis <> Tested-by: Michael Sevakis <>
2013-03-11jz4740: a few minor fixesMarcin Bukat1-1/+1
This was spotted while playing with qemu-jz: 1) rockbox reads TECR and TESR which are described as write-only registers. Datasheet doesn't mention what happens if they are readed. Apparently this doesn't have fatal side effects. It comes down to two defines from jz4740.h __tcu_stop_counter(n) and __tcu_start_counter(n) which use read-modify-write sequence. 2) rockbox accesses out of bound offset 0xd4 in DMA memspace. It comes from dis_irq() in system-jz4740.c. NUM_DMA is 6 but DMA channels are 0-5 so (irq <= IRQ_DMA_0 + NUM_DMA)) bound check is wrong. This are *NOT* tested on device. Change-Id: I29dff6a4f828030877b7d50fbcc98866478b9e3d Reviewed-on: Reviewed-by: Bertrik Sikken <> Tested-by: Purling Nayuki <> Reviewed-by: Marcin Bukat <>
2012-05-07remove debug-target.hRafaël Carré2-1/+0
2012-05-07remove unused prototypesRafaël Carré1-4/+0
2012-03-03Revise the PCM callback system after adding multichannel audio.Michael Sevakis1-7/+5
Additional status callback is added to pcm_play/rec_data instead of using a special function to set it. Status includes DMA error reporting to the status callback. Playback and recording callback become more alike except playback uses "const void **addr" (because the data should not be altered) and recording uses "void **addr". "const" is put in place throughout where appropriate. Most changes are fairly trivial. One that should be checked in particular because it isn't so much is telechips, if anyone cares to bother. PP5002 is not so trivial either but that tested as working. Change-Id: I4928d69b3b3be7fb93e259f81635232df9bd1df2 Reviewed-on: Reviewed-by: Michael Sevakis <> Tested-by: Michael Sevakis <>
2012-02-28lcd drivers: Convert lcd_[remote_]framebuffer to a pointerJonathan Gordon1-2/+2
Change all lcd drivers to using a pointer to the static framebuffer instead of directly accessing the static array. This will let us later do fun things like dynamic framebuffer sizes (RaaA) or ability to use different buffers for different layers (dynamic skin backdrops!) Change-Id: I0a4d58a9d7b55e6c932131b929e5d4c9f9414b06