Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

ata: Prefer using "virtual" sector size where possible

Normally, if a device uses larger physical sector size than the logical
size and supports so-called "512e" mode, we let the device deal with
partial sector reads/writes.

However, if MAX_VIRT_SECTOR_SIZE is defined, we support
partitioning/filesystems that use a larger "virtual" sector than the
logical sector. typically this matches the physical sector size of the
drive, which means that despite a small logical sector size, all I/O
is done in terms of the physical sector size.

Therefore, when MAX_VIRT_SECTOR_SIZE and MAX_PHYS_SECTOR_SIZE are
enabled (currently only ipod5g and ipod6g), prefer software-based
partial sector I/O.

Change-Id: I0815ad0a2f987b89bb2debfbf3d0ed64cdf85525

+24
+5
firmware/common/disk.c
··· 434 434 } 435 435 #endif /* MAX_VIRT_SECTOR_SIZE */ 436 436 } 437 + 438 + #if defined(MAX_VIRT_SECTOR_SIZE) && defined(MAX_PHYS_SECTOR_SIZE) 439 + if (mounted) 440 + ata_set_phys_sector_mult(disk_sector_multiplier[drive]); 441 + #endif 437 442 } 438 443 439 444 disk_writer_unlock();
+15
firmware/drivers/ata-common.c
··· 238 238 /* Check if drive really needs emulation - if we can access 239 239 sector 1 then assume the drive supports "512e" and will handle 240 240 it better than us, so ignore the large physical sectors. 241 + 242 + The exception here is if the device is partitioned to use 243 + larger-than-logical "virtual" sectors; in that case we will 244 + use whichever one (ie physical/"virtual") is larger. 241 245 */ 242 246 char throwaway[__MAX_VARIABLE_LOG_SECTOR]; 243 247 rc = ata_transfer_sectors(1, 1, &throwaway, false); ··· 252 256 memset(&sector_cache, 0, sizeof(sector_cache)); 253 257 254 258 return 0; 259 + } 260 + 261 + void ata_set_phys_sector_mult(unsigned int mult) 262 + { 263 + unsigned int max = MAX_PHYS_SECTOR_SIZE/log_sector_size; 264 + /* virtual sector could be larger than pyhsical sector */ 265 + if (!mult || mult > max) 266 + mult = max; 267 + /* It needs to be at _least_ the size of the real multiplier */ 268 + if (mult > phys_sector_mult) 269 + phys_sector_mult = mult; 255 270 } 256 271 257 272 #endif /* MAX_PHYS_SECTOR_SIZE */
+4
firmware/export/ata.h
··· 235 235 236 236 #define ATA_IDENTIFY_WORDS 256 237 237 238 + #ifdef MAX_PHYS_SECTOR_SIZE 239 + void ata_set_phys_sector_mult(unsigned int mult); 240 + #endif 241 + 238 242 #endif /* __ATA_H__ */