summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/tms320dm320
AgeCommit message (Collapse)AuthorFilesLines
2023-01-13Remove buflib allocation names, part twoAidan MacDonald1-1/+1
Remove allocation names from the buflib API and fix up all callers. Change-Id: I3df922e258d5f0d711d70e72b56b4ed634fb0f5a
2023-01-12Add INIT_ATTR to i2c_init()Aidan MacDonald1-1/+1
It's usually only called from init() in main.c, so this is safe. There is one more call in system-dm320.c from system_init(), but that's also "safe". I don't know if it's okay to call i2c_init() twice, but presumably it works... Change-Id: I9c1cd918d162d9955f7cf03209e836cbd5e30c57
2022-10-13Revert "Remove YUV blitting functions and LCD modes"Solomon Peachy1-1/+85
This reverts commit fe6aa21e9eb88f49005863efd2003d0982920048. Change-Id: I8bb1e5d6c52ed1478002d2140ef494ec5d62b8e3
2022-10-03Remove YUV blitting functions and LCD modesAidan MacDonald1-85/+1
None of this is needed now that mpegplayer is gone. Change-Id: I360366db8513e4d988021e8d7b7d8eb09930efb8
2022-09-30Define LCD_STRIDEFORMAT unconditionallyAidan MacDonald1-2/+2
Instead of putting "#ifdef LCD_STRIDEFORMAT" at every usage of the macro it's simpler to have config.h define LCD_STRIDEFORMAT to the default of horizontal stride when the target leaves it unspecified. Change-Id: Ib187012aad65ac678dbd837b1464a83bad722411
2021-10-16usb: introduce new control request APIAidan MacDonald1-1/+1
Change-Id: I6545d8985ab683c026f28f6a7c0e23b40d0a6506
2021-09-20usb: rename usb_drv_recv() to usb_recv_recv_nonblocking()Aidan MacDonald1-5/+3
IMHO the current name is somewhat misleading: - usb_drv_send() is blocking and we have usb_drv_send_nonblocking() for the non-blocking case. This inconsistent naming can only promote confusion. (And what would we call a blocking receive?) - Other hardware abstraction APIs in Rockbox are usually blocking: storage, LCD, backlight, audio... in other words, blocking is the default expected behavior, with non-blocking calls being a rarity. Change-Id: I05b41088d09eab582697674f4f06fdca0c8950af
2021-07-25pcm: Remove unused function pcm_play_dma_get_peak_buffer()Aidan MacDonald3-38/+0
Change-Id: Ifd20fb14a22489cdb99154c01f69809a1e70d0c5
2021-07-10Sansa Connect: Ensure LCD starts before backlightTomasz Moń1-0/+1
Extra delay prevents white flash after hold switch release. Change-Id: Ib0d33937dcbb738b913388e7df92ffdf9346c9f9
2021-07-10Sansa Connect: Use deviceid in USB Serial NumberTomasz Moń4-0/+118
Atmel AT88SC6416C CryptoMemory is almost I2C compatible. The device is connected to bitbanged I2C bus shared with compliant I2C devices. Change-Id: Iec54702db1bdfb93c01291eef18ec60391c63b16
2021-07-09Sansa Connect: Fix reported CPU frequencyTomasz Moń7-30/+66
Make frequency related comments accurate. Disable UART0 clock. Change-Id: I224a3d6656ad53165dcff68ed716fa2c6863240d
2021-07-09DM320: Regorganize LCD and TTB memory layoutTomasz Moń2-40/+80
Do not introduce any change for M:Robe 500 as it uses the two LCD frames in non-obvious way. Sansa Connect and Creative ZVM use only single front framebuffer. Place TTB at DRAM end to minimize memory loss due to alignment. Reserve as little as possible memory for the LCD frames. On Sansa Connect this change extends audio buffer by 858 KiB. Change-Id: I21bdeec4cfba86d71803a39acd651a87e73767e6
2021-07-07Sansa Connect: Reduce USB RX buffers from 129 to 2Tomasz Moń2-24/+27
Reducing number of fake RX buffers saves a bit more than 127 KiB RAM. Fix compilation with CPPI logging enabled. Change-Id: If1ad3a6fc251e284caaac78c2406a58f3d6547bb
2021-07-07Sansa Connect: Prevent unresponsive interfaceTomasz Moń1-1/+13
AVR interrupt signal can remain active if the state has changed during state read. In such case, there won't be intterupt and the interface would appear unresponsive until AVR thread received event (e.g. USB connection/disconnect). Solve the issue by not waiting for event if AVR interrupt signal is active prior to event wait. Change-Id: I86e388c7cd6da76e3abe7bf7114940f331e4c308
2021-07-07Sansa Connect: Read HDQ battery dataTomasz Moń3-1/+137
Make it possible for target to provide voltage, percentage and time to empty values. The voltage measurement is nice to have in debug menu even if the actions are taken only based on percentage. Perform battery level estimation based on voltage only if percentage is not available. Use time to empty based on actual power consumption. This makes the estimated runtime displayed in Rockbox Info to react to backlight setting. The bq27000 updates time to empty estimate every 5.12 seconds so it is possible to see the estimate with backlight off on the screen if user enters Rockbox Info, activates hold switch, waits 11 seconds and releases the hold switch. Change-Id: Iafe3fa0fb334e3428e3a0ad05b2c020d208dc934
2021-07-05Sansa Connect: Power off LCD to save powerTomasz Moń3-41/+84
Prevent startup screen flash by properly using AVR LCM functions. Power off LCD when not needed to improve battery runtime. Change-Id: I76e3c5c0208774f189fbc6f7d7b3c9e22c062285
2021-07-04Sansa Connect: Fix power off panic screenTomasz Moń2-2/+10
Queue power off requests because power_off() can be called within tick context that must not acquire mutex. Change-Id: I6f1a8f81d15518876cd03556118fc9eb37b8175f
2021-07-04Sansa Connect: Initial libertas WiFi driver portTomasz Moń4-2/+142
Import non-free firmware image from linux-firmware package. Firmware loading works but is disabled at compile time because just loading firmware without configuring device results in higher power consumption without any benefit to end user. Change-Id: I8fd252c49385ede1ea4e0f9b1e29adeb331ab8ae
2021-06-27Sansa Connect: Ensure adequate AVR Slave Select delayTomasz Moń1-1/+2
Waiting 10 us between selecting slave and transmitting data on SPI resolves spurious startup glitches. Cache last read monotime value as it can differ from the first one. Change-Id: Ia6ac5696f6ee2bc3c6a8be27e33aaddd9ff4ce2a
2021-06-27Sansa Connect: Discard invalid monotime readsTomasz Moń1-22/+39
Read monotime twice in a row and only accept the value if it matches or the two reads are 1 second apart. Change-Id: Ibd289103a20404dd1b2bbd131fdfa8905852c788
2021-06-27Sansa Connect: More reliable AVR communicationTomasz Moń1-15/+16
AVR requires bigger delays between retries. Read state instead of version for synchronization purposes as it shifts more bytes. Change-Id: Ib7fa980496d3bc7744a086b45e1865861ef58b88
2021-06-25Sansa Connect: Retry AVR commands only 3 timesTomasz Moń1-16/+33
If the commands repeatedly fail it is likely that the AVR is not programmed. In such case simply continue normal operation. This is especially important in bootloader as it makes it possible to load new rockbox build using bootloader USB mode. Otherwise, the only recovery option would be to use I2C serial. Change-Id: I4b0999833e9a906ec6353bdfdd5b68211f07ac81
2021-06-25Sansa Connect: Implement RTC functionalityTomasz Moń1-23/+159
Use 32-bit monotime AVR counter for time tracking. Set the time by adding fixed offset to the counter value. Store the offset in rockbox directory to make it persistent between reboots. Do not implement alarm functionality as wakeup is only possible from sleep and not from complete power off. Change-Id: I615c7eb4df8ab0619dcbfcff107bc7051a15aace
2021-06-25Sansa Connect: Manually drive SPI Slave SelectTomasz Moń1-2/+19
Keep Slave Select active during command transmission. This relaxes timing requirements on the AVR side. Change-Id: Ia1a6cf45aba3c11f6aeaa7441c6793807ca827f0
2021-06-22Sansa Connect: Refactor AVR command handlingTomasz Moń3-103/+234
Add defines for all commands handled by AVR, including the unknown opcodes (0xC5, 0xD3, 0xD4, 0xD5, 0xD6). Properly synchronize with AVR and keep repeating command until it looks like AVR has accepted it. Change-Id: I3d42e973f135e33092c71c9887421906a900ab58
2021-06-20Sansa Connect: Indicate charging statusTomasz Moń2-27/+40
Consider battery level down to 0 as safe as OF continues to operate normally even when at level 0. Change-Id: Ie3889e5662b9fa6588e20ad02d8953f29e28800c
2021-06-15DM320: Use SD/MMC data done interruptTomasz Moń1-17/+32
Wait on semaphore until DMA finishes instead of busy waiting. This allows the CPU to be used by other tasks during transfers. Increase peripheral clock frequency, divide AHB by 2 instead of 3. Function clock frequency is AHB divided by MMC divider + 1. Change-Id: Ic890634da7e3541962ea3501eae8fa2ca2db606a
2021-06-14Sansa Connect: Properly setup internal speakerTomasz Moń1-52/+56
Switch to internal speaker when headphones are disconnected. Change-Id: I7c04ac139ad540d85f960e9dadc2faaf4f856055
2021-06-12Sansa Connect: Disable endpoint double bufferingTomasz Moń1-2/+8
Disabling double buffering results in expected CPPI TX behaviour. With the double buffering enabled, sending single ZLP resulted in two ZLPs being available. The two ZLPs is problematic because this causes Windows to reset USB device after failed SCSI command. The problematic sequence on Windows 10 was as follows: * Host sends SCSI Mode Sense(6) Informational Exceptions Control(0x1C) * Device sends ZLP * Device sends command failed response With endpoint double buffering enabled the ZLP was read twice by host. As host was expecting command response on the second read (and got ZLP instead), host attempts recovery by resetting USB device and retrying. Change-Id: I64e95998f429ffb7b14143d956b1f29d20218d14
2021-06-10Sansa Connect: Remove fake battery voltage scaleTomasz Moń2-68/+8
Use battery percentage as reported by AVR. Change-Id: Id697d460b240798eb0b103f9e1f419906b87e9ca
2021-06-10Sansa Connect: Add missing includeTomasz Moń1-0/+1
Include usb.h to have usb_acknowledge() prototype. Change-Id: I2dd951315a93e7c1c456358d715f9ec44bf9e5af
2021-06-09Sansa Connect: Working USB Mass StorageTomasz Moń3-17/+9
Acknowledge SYS_USB_CONNECTED in all queues so USB task can gain exclusive access to the storage. Reduce CPPI requeue timeout to speed up disk access. Change-Id: I322aae4cac679696bb8186ccacf838a18f0715e9
2021-06-09Sansa Connect: Fix sending ZLP on non-zero endpointTomasz Moń1-2/+13
This fixes panic when mass storage driver sends failed result. Change-Id: I14ae975b1f23aee7bc2f7bad6ed68dde29cf5e36
2021-06-09Sansa Connect: Fix bulk transfers greater than 64 bytesTomasz Moń1-4/+19
Correctly set endpoint maximum packet size so host will not consider end of transfer after receiving first packet when transfer is larger than 64 bytes (at High Speed the endpoint max packet size was set to 64 but according to descriptor it is 512). Split DMA transfers up to CPPI_MAX_FRAG so we get single interrupt after each call to tnetv_cppi_send(). Change-Id: I385b66bc5d71975a4e3e9167efac0b1334bd3ffc
2021-06-09DM320: Fix SDHC response format 2 handlingTomasz Moń1-9/+17
Return complete R2 response to caller. Due to incorrect bitfield handling only bits [127-96] were ever returned to caller. Change-Id: I83726af35fb24a8051fcca8b8d019ad89d17500e
2021-06-06Sansa Connect: Initial TNETV105 driver portTomasz Moń7-54/+3033
Port USB driver from Sansa Connect Linux kernel sources. The device successfully enumerates and responds to SCSI commands but actual disk access does not work. The SCSI response sent to host mentions that both internal storage and microsd card are not present. Change-Id: Ic6c07da12382c15c0b069f23a75f7df9765b7525
2021-06-05DM320: Fix buffer overrun in sdmmc driverTomasz Moń1-5/+4
Modify count, buffer and start address only after successful transfer. This makes the retry operation to use the same address and buffer as the just failed transfer. Change-Id: I4f49bbdc861d634e33ea5e939a9693474411d24d
2021-05-21Sansa Connect: Clear recoverzap parameterTomasz Moń2-9/+9
Clearing recoverzap parameter exists the Recovery Mode. This makes it possible to run Rockbox on Sansa Connect without relying on original Linux firmware. Enable write-through cache on flash memory as write-back complicates handling without any real benefits. The flash memory accepts commands as series of writes at predefined addresses, so it is important that the cache does not interfere with the writes. Change-Id: I219f962f20953d84df43012cf16bbb16d673add8
2020-11-12pcm: Further cleanup of unused bits of the PCM ACPI:Solomon Peachy3-15/+0
* pcm_get_bytes_remaining() * pcm_calculate_peaks() * pcm_get_peak_buffer() Nothing in-tree uses these at all (except for the lua plugin wrapper) Change-Id: I971b7beed6760250c8b1ce58f401a601e1e2d585
2020-10-31pcm: Get rid of pcm_play_pause() and associated APIsSolomon Peachy3-33/+0
Nothing in the core has used it for some time. It's exported to the plugin API but the last plugins to use it were switched to the mixer API back in 2011. This allows us to get rid of pcm_play_dma_pause() from all audio drivers Change-Id: Ic3fa02592316f84963e41d792d1cabb436d1ff6b
2020-10-26LCD core move buf ptr and address look up function viewport structWilliam Wilgus2-3/+3
I'm currently running up against the limitations of the lcd_draw functions I want these functions to be able to be used on any size buffer not just buffers with a stride matching the underlying device [DONE] allow the framebuffer to be decoupled from the device framebuffer [DONE need examples] allow for some simple blit like transformations [DONE] remove the device framebuffer from the plugin api [DONE}ditto remote framebuffer [DONE] remove _viewport_get_framebuffer you can call struct *vp = lcd_set_viewport(NULL) and vp->buffer->fb_ptr while remote lcds may compile (and work in the sim) its not been tested on targets [FIXED] backdrops need work to be screen agnostic [FIXED] screen statusbar is not being combined into the main viewport correctly yet [FIXED] screen elements are displayed incorrectly after switch to void* [FIXED] core didn't restore proper viewport on splash etc. [NEEDS TESTING] remote lcd garbled data [FIXED] osd lib garbled screen on bmp_part [FIXED] grey_set_vp needs to return old viewport like lcd_set_viewport [FIXED] Viewport update now handles viewports with differing buffers/strides by copying to the main buffer [FIXED] splash on top of WPS leaves old framebuffer data (doesn't redraw) [UPDATE] refined this a bit more to have clear_viewport set the clean bit and have skin_render do its own screen clear scrolling viewports no longer trigger wps refresh also fixed a bug where guisyncyesno was displaying and then disappearing [ADDED!] New LCD macros that allow you to create properly size frame buffers in you desired size without wasting bytes (LCD_ and LCD_REMOTE_) LCD_STRIDE(w, h) same as STRIDE_MAIN LCD_FBSTRIDE(w, h) returns target specific stride for a buffer W x H LCD_NBELEMS(w, h) returns the number of fb_data sized elemenst needed for a buffer W x H LCD_NATIVE_STRIDE(s) conversion between rockbox native vertical and lcd native stride (2bitH) test_viewports.c has an example of usage [FIXED!!] 2bit targets don't respect non-native strides [FIXED] Few define snags Change-Id: I0d04c3834e464eca84a5a715743a297a0cefd0af
2020-10-13Fix a pile of yellow in the bootloaderSolomon Peachy2-35/+33
Change-Id: Ia89a33bbb13683566e421ac2a002baa20cdb07de
2017-10-26Unify storage threads into oneMichael Sevakis1-94/+45
* 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
2017-08-16Fix stupid omissionFranklin Wei1-1/+0
Change-Id: I9d65b8feeeb4c31e14fa60b370a12c0cc8b13f54
2017-08-16Remove mutex_* calls from the MR:500 SPI driverFranklin Wei1-6/+0
As before, they would trigger a panic. Change-Id: I3c140f2897a9d3ed21e13f0a9e45025ede311de5
2017-03-12Do some housekeeping with fat.h and SECTOR_SIZEMichael Sevakis1-2/+0
Many includes of fat.h are pointless. Some includes are just for SECTOR_SIZE. Add a file 'firmware/include/fs_defines.h' for that and to define tuneable values that were scattered amongst various headers. Remove some local definitions of SECTOR_SIZE since they have to be in agreement with the rest of the fs code anyway. (We'll see what's in fact pointless in a moment ;) Change-Id: I9ba183bf58bd87f5c45eba7bd675c7e2c1c18ed5
2016-05-25Sansa Connect: change bootloader linker fileTomasz Moń2-7/+14
This change ensures that Sansa Connect bootloader.bin will fit in its flash partition. Fix _flash_sizem calculation, division was not working properly because FLASHSIZE included subtraction and defined value was not in parenthesis. Prior to this change _flash_sizem was 0x00800000, now it is correctly set to 4 in case of Sansa Connect and 8 in case of other TMS320DM320 players. This significantly improves boot time as cache is now enabled only for real flash memory region. Change-Id: If3e50a3075c840dcb69dfafe5bba608a0acd2bf8
2015-01-12Get rid of stupid _backlight_* function namesMarcin Bukat8-30/+30
_remote_backlight_* and _buttonlight_* are cleaned as well Change-Id: I73653752831bbe170c26ba95d3bc04c2e3a5cf30
2014-08-30Rewrite filesystem code (WIP)Michael Sevakis1-27/+8
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: http://gerrit.rockbox.org/566 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested: Michael Sevakis <jethead71@rockbox.org>
2014-01-05Add missing kernel.h includes (hopefully all of them), take #2.Thomas Martitz1-1/+1
Change-Id: I62cedf992bb096987050621cfc34f0432e9da170