Files
Aaru/SCSI/Modes/2A.cs

251 lines
9.3 KiB
C#
Raw Normal View History

2017-12-21 02:03:21 +00:00
// /***************************************************************************
2020-02-27 12:31:23 +00:00
// Aaru Data Preservation Suite
2017-12-21 02:03:21 +00:00
// ----------------------------------------------------------------------------
//
// Filename : 2A.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Device structures decoders.
//
// --[ Description ] ----------------------------------------------------------
//
// Decodes SCSI MODE PAGE 2Ah: CD-ROM capabilities page.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2022-02-18 10:02:39 +00:00
// Copyright © 2011-2022 Natalia Portillo
2017-12-21 02:03:21 +00:00
// ****************************************************************************/
2022-03-07 07:36:42 +00:00
namespace Aaru.Decoders.SCSI;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
2017-12-21 02:03:21 +00:00
using System.Text;
2020-02-27 00:33:24 +00:00
using Aaru.CommonTypes.Structs.Devices.SCSI.Modes;
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
public static partial class Modes
2017-12-21 02:03:21 +00:00
{
2022-03-06 13:29:37 +00:00
#region Mode Page 0x2A: CD-ROM capabilities page
public static string PrettifyModePage_2A(byte[] pageResponse) =>
PrettifyModePage_2A(ModePage_2A.Decode(pageResponse));
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
public static string PrettifyModePage_2A(ModePage_2A modePage)
{
if(modePage is null)
return null;
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
ModePage_2A page = modePage;
var sb = new StringBuilder();
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
sb.AppendLine("SCSI CD-ROM capabilities page:");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.PS)
sb.AppendLine("\tParameters can be saved");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.AudioPlay)
sb.AppendLine("\tDrive can play audio");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.Mode2Form1)
sb.AppendLine("\tDrive can read sectors in Mode 2 Form 1 format");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.Mode2Form2)
sb.AppendLine("\tDrive can read sectors in Mode 2 Form 2 format");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.MultiSession)
sb.AppendLine("\tDrive supports multi-session discs and/or Photo-CD");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.CDDACommand)
sb.AppendLine("\tDrive can read digital audio");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.AccurateCDDA)
sb.AppendLine("\tDrive can continue from streaming loss");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.Subchannel)
sb.AppendLine("\tDrive can read uncorrected and interleaved R-W subchannels");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.DeinterlaveSubchannel)
sb.AppendLine("\tDrive can read, deinterleave and correct R-W subchannels");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.C2Pointer)
sb.AppendLine("\tDrive supports C2 pointers");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.UPC)
sb.AppendLine("\tDrive can read Media Catalogue Number");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.ISRC)
sb.AppendLine("\tDrive can read ISRC");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
switch(page.LoadingMechanism)
{
case 0:
sb.AppendLine("\tDrive uses media caddy");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
case 1:
sb.AppendLine("\tDrive uses a tray");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
case 2:
sb.AppendLine("\tDrive is pop-up");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
case 4:
sb.AppendLine("\tDrive is a changer with individually changeable discs");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
case 5:
sb.AppendLine("\tDrive is a changer using cartridges");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
default:
2022-03-07 07:36:42 +00:00
sb.AppendFormat("\tDrive uses unknown loading mechanism type {0}", page.LoadingMechanism).AppendLine();
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
}
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.Lock)
sb.AppendLine("\tDrive can lock media");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.PreventJumper)
{
sb.AppendLine("\tDrive power ups locked");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
sb.AppendLine(page.LockState ? "\tDrive is locked, media cannot be ejected or inserted"
: "\tDrive is not locked, media can be ejected and inserted");
}
else
2022-03-07 07:36:42 +00:00
sb.AppendLine(page.LockState ? "\tDrive is locked, media cannot be ejected, but if empty, can be inserted"
2022-03-06 13:29:37 +00:00
: "\tDrive is not locked, media can be ejected and inserted");
2018-06-22 08:08:38 +01:00
2022-03-06 13:29:37 +00:00
if(page.Eject)
sb.AppendLine("\tDrive can eject media");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.SeparateChannelMute)
sb.AppendLine("\tEach channel can be muted independently");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.SeparateChannelVolume)
sb.AppendLine("\tEach channel's volume can be controlled independently");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.SupportedVolumeLevels > 0)
sb.AppendFormat("\tDrive supports {0} volume levels", page.SupportedVolumeLevels).AppendLine();
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.BufferSize > 0)
sb.AppendFormat("\tDrive has {0} Kbyte of buffer", page.BufferSize).AppendLine();
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.MaximumSpeed > 0)
sb.AppendFormat("\tDrive's maximum reading speed is {0} Kbyte/sec.", page.MaximumSpeed).AppendLine();
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.CurrentSpeed > 0)
sb.AppendFormat("\tDrive's current reading speed is {0} Kbyte/sec.", page.CurrentSpeed).AppendLine();
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.ReadCDR)
{
sb.AppendLine(page.WriteCDR ? "\tDrive can read and write CD-R" : "\tDrive can read CD-R");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.Method2)
sb.AppendLine("\tDrive supports reading CD-R packet media");
}
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.ReadCDRW)
sb.AppendLine(page.WriteCDRW ? "\tDrive can read and write CD-RW" : "\tDrive can read CD-RW");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.ReadDVDROM)
sb.AppendLine("\tDrive can read DVD-ROM");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.ReadDVDR)
sb.AppendLine(page.WriteDVDR ? "\tDrive can read and write DVD-R" : "\tDrive can read DVD-R");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.ReadDVDRAM)
sb.AppendLine(page.WriteDVDRAM ? "\tDrive can read and write DVD-RAM" : "\tDrive can read DVD-RAM");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.Composite)
sb.AppendLine("\tDrive can deliver a composite audio and video data stream");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.DigitalPort1)
sb.AppendLine("\tDrive supports IEC-958 digital output on port 1");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.DigitalPort2)
sb.AppendLine("\tDrive supports IEC-958 digital output on port 2");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.SDP)
sb.AppendLine("\tDrive contains a changer that can report the exact contents of the slots");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.CurrentWriteSpeedSelected > 0)
2022-11-13 19:38:02 +00:00
switch(page.RotationControlSelected)
{
case 0:
sb.AppendFormat("\tDrive's current writing speed is {0} Kbyte/sec. in CLV mode",
page.CurrentWriteSpeedSelected).AppendLine();
break;
case 1:
sb.AppendFormat("\tDrive's current writing speed is {0} Kbyte/sec. in pure CAV mode",
page.CurrentWriteSpeedSelected).AppendLine();
break;
}
2022-03-06 13:29:37 +00:00
else
{
if(page.MaxWriteSpeed > 0)
2022-03-07 07:36:42 +00:00
sb.AppendFormat("\tDrive's maximum writing speed is {0} Kbyte/sec.", page.MaxWriteSpeed).AppendLine();
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.CurrentWriteSpeed > 0)
sb.AppendFormat("\tDrive's current writing speed is {0} Kbyte/sec.", page.CurrentWriteSpeed).
AppendLine();
}
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.WriteSpeedPerformanceDescriptors != null)
2022-03-07 07:36:42 +00:00
foreach(ModePage_2A_WriteDescriptor descriptor in page.WriteSpeedPerformanceDescriptors.Where(descriptor =>
descriptor.WriteSpeed > 0))
2022-11-13 19:38:02 +00:00
switch(descriptor.RotationControl)
{
case 0:
sb.AppendFormat("\tDrive supports writing at {0} Kbyte/sec. in CLV mode",
descriptor.WriteSpeed).AppendLine();
break;
case 1:
sb.AppendFormat("\tDrive supports writing at is {0} Kbyte/sec. in pure CAV mode",
descriptor.WriteSpeed).AppendLine();
break;
}
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.TestWrite)
sb.AppendLine("\tDrive supports test writing");
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
if(page.ReadBarcode)
sb.AppendLine("\tDrive can read barcode");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.SCC)
sb.AppendLine("\tDrive can read both sides of a disc");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.LeadInPW)
sb.AppendLine("\tDrive an read raw R-W subchannel from the Lead-In");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.CMRSupported == 1)
sb.AppendLine("\tDrive supports DVD CSS and/or DVD CPPM");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
if(page.BUF)
sb.AppendLine("\tDrive supports buffer under-run free recording");
2017-12-21 02:03:21 +00:00
2022-03-06 13:29:37 +00:00
return sb.ToString();
2017-12-21 02:03:21 +00:00
}
2022-03-06 13:29:37 +00:00
#endregion Mode Page 0x2A: CD-ROM capabilities page
2017-12-21 02:03:21 +00:00
}