Remove SpeedTable, add probe_disc(), named constants, clean architecture

- Removed SpeedTable entirely — drive manages speeds after probe
- Renamed read_speed_table() → probe_disc()
- Named all SCSI constants: SUB_CMD_UNLOCK, SUB_CMD_INIT, SUB_CMD_PROBE,
  INIT_ADDR_BD, INIT_ADDR_UHD, PROBE_COARSE_END, PROBE_FINE_END, etc.
- Auto-detect BD vs UHD from disc capacity for correct probe init address
- Fixed NOMINAL_SPEED_B (was invalid CDB, removed — single max instead)
- Added session.set_speed() for simple speed control
- Error recovery: re-init on first error, BD2x on repeated errors
- Batch size uses full kernel limit (was 80%, now 100%)
- Clean variant_a/variant_b with named constants

API: open() → wait_ready() → init() → probe_disc() → scan() → read
This commit is contained in:
MattJackson
2026-04-09 15:17:25 -07:00
parent 09f5bb7816
commit 65996ade59
8 changed files with 150 additions and 270 deletions
+15 -10
View File
@@ -3,21 +3,20 @@
//! Three-step open:
//! 1. `open()` — open device, identify drive. Always OEM.
//! 2. `wait_ready()` — wait for disc to spin up. Call before reading.
//! 3. `init()` — activate custom firmware. Optional, caller decides.
//! 3. `init()` — activate custom firmware. Removes riplock.
//! 4. `probe_disc()` — probe disc surface. Drive learns optimal speeds.
use std::path::Path;
use crate::error::{Error, Result};
use crate::scsi::ScsiTransport;
use crate::identity::DriveId;
use crate::profile::{self, DriveProfile, ProfileMatch};
use crate::profile::{self, DriveProfile};
use crate::platform::PlatformDriver;
use crate::platform::mt1959::Mt1959;
use crate::speed::SpeedTable;
pub struct DriveSession {
scsi: Box<dyn ScsiTransport>,
driver: Box<dyn PlatformDriver>,
pub speed_table: SpeedTable,
pub profile: DriveProfile,
pub platform: profile::Platform,
pub drive_id: DriveId,
@@ -42,7 +41,6 @@ impl DriveSession {
Ok(DriveSession {
scsi: transport,
driver,
speed_table: SpeedTable::new(),
platform: m.platform,
profile: m.profile,
drive_id,
@@ -74,15 +72,16 @@ impl DriveSession {
&self.device_path
}
/// Initialize drive — unlock + firmware upload.
/// Initialize drive — unlock + firmware upload. Removes riplock.
pub fn init(&mut self) -> Result<()> {
self.driver.init(self.scsi.as_mut())
}
/// Read speed zones from disc into speed table.
/// Requires init() first. Optional — without this, drive manages speed itself.
pub fn read_speed_table(&mut self) -> Result<()> {
self.driver.read_speed_table(self.scsi.as_mut(), &mut self.speed_table)
/// Probe disc surface so the drive firmware learns optimal read speeds
/// per region. After this the host reads at max speed and the drive
/// manages zones internally.
pub fn probe_disc(&mut self) -> Result<()> {
self.driver.probe_disc(self.scsi.as_mut())
}
pub fn is_ready(&self) -> bool {
@@ -111,6 +110,12 @@ impl DriveSession {
Ok(result.bytes_transferred)
}
pub fn set_speed(&mut self, speed_kbs: u16) {
let cdb = crate::scsi::build_set_cd_speed(speed_kbs);
let mut dummy = [0u8; 0];
let _ = self.scsi_execute(&cdb, crate::scsi::DataDirection::None, &mut dummy, 5_000);
}
pub fn eject(&mut self) -> Result<()> {
let allow_cdb = [0x1Eu8, 0, 0, 0, 0x00, 0];
let mut buf = [0u8; 0];