Files
Aaru/SCSI/Modes/2A.cs

243 lines
9.7 KiB
C#
Raw Normal View History

2017-12-21 02:03:21 +00:00
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// 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/>.
//
// ----------------------------------------------------------------------------
2020-01-03 17:51:28 +00:00
// Copyright © 2011-2020 Natalia Portillo
2017-12-21 02:03:21 +00:00
// ****************************************************************************/
using System.Diagnostics.CodeAnalysis;
using System.Linq;
2017-12-21 02:03:21 +00:00
using System.Text;
using DiscImageChef.CommonTypes.Structs.Devices.SCSI.Modes;
2017-12-21 02:03:21 +00:00
namespace DiscImageChef.Decoders.SCSI
{
2019-11-25 00:54:38 +00:00
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
2017-12-21 02:03:21 +00:00
public static partial class Modes
{
#region Mode Page 0x2A: CD-ROM capabilities page
2018-12-31 13:17:27 +00:00
public static string PrettifyModePage_2A(byte[] pageResponse) =>
PrettifyModePage_2A(ModePage_2A.Decode(pageResponse));
2017-12-21 02:03:21 +00:00
public static string PrettifyModePage_2A(ModePage_2A modePage)
2017-12-21 02:03:21 +00:00
{
2019-11-25 00:54:38 +00:00
if(modePage is null)
return null;
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
ModePage_2A page = modePage;
var sb = new StringBuilder();
2017-12-21 02:03:21 +00:00
sb.AppendLine("SCSI CD-ROM capabilities page:");
2019-11-25 00:54:38 +00:00
if(page.PS)
sb.AppendLine("\tParameters can be saved");
if(page.AudioPlay)
sb.AppendLine("\tDrive can play audio");
if(page.Mode2Form1)
sb.AppendLine("\tDrive can read sectors in Mode 2 Form 1 format");
if(page.Mode2Form2)
sb.AppendLine("\tDrive can read sectors in Mode 2 Form 2 format");
if(page.MultiSession)
sb.AppendLine("\tDrive supports multi-session discs and/or Photo-CD");
if(page.CDDACommand)
sb.AppendLine("\tDrive can read digital audio");
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
if(page.AccurateCDDA)
sb.AppendLine("\tDrive can continue from streaming loss");
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
if(page.Subchannel)
sb.AppendLine("\tDrive can read uncorrected and interleaved R-W subchannels");
if(page.DeinterlaveSubchannel)
sb.AppendLine("\tDrive can read, deinterleave and correct R-W subchannels");
if(page.C2Pointer)
sb.AppendLine("\tDrive supports C2 pointers");
if(page.UPC)
sb.AppendLine("\tDrive can read Media Catalogue Number");
if(page.ISRC)
sb.AppendLine("\tDrive can read ISRC");
2017-12-21 02:03:21 +00:00
switch(page.LoadingMechanism)
{
case 0:
sb.AppendLine("\tDrive uses media caddy");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 1:
sb.AppendLine("\tDrive uses a tray");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 2:
sb.AppendLine("\tDrive is pop-up");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 4:
sb.AppendLine("\tDrive is a changer with individually changeable discs");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
case 5:
sb.AppendLine("\tDrive is a changer using cartridges");
2019-11-25 00:54:38 +00:00
2017-12-21 02:03:21 +00:00
break;
default:
2019-11-25 00:54:38 +00:00
sb.AppendFormat("\tDrive uses unknown loading mechanism type {0}", page.LoadingMechanism).
AppendLine();
2017-12-21 02:03:21 +00:00
break;
}
2019-11-25 00:54:38 +00:00
if(page.Lock)
sb.AppendLine("\tDrive can lock media");
2017-12-21 02:03:21 +00:00
if(page.PreventJumper)
{
sb.AppendLine("\tDrive power ups locked");
2019-11-25 00:54:38 +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");
2017-12-21 02:03:21 +00:00
}
else
sb.AppendLine(page.LockState
? "\tDrive is locked, media cannot be ejected, but if empty, can be inserted"
: "\tDrive is not locked, media can be ejected and inserted");
2018-06-22 08:08:38 +01:00
2019-11-25 00:54:38 +00:00
if(page.Eject)
sb.AppendLine("\tDrive can eject media");
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
if(page.SeparateChannelMute)
sb.AppendLine("\tEach channel can be muted independently");
if(page.SeparateChannelVolume)
sb.AppendLine("\tEach channel's volume can be controlled independently");
2017-12-21 02:03:21 +00:00
if(page.SupportedVolumeLevels > 0)
sb.AppendFormat("\tDrive supports {0} volume levels", page.SupportedVolumeLevels).AppendLine();
2019-11-25 00:54:38 +00:00
if(page.BufferSize > 0)
sb.AppendFormat("\tDrive has {0} Kbyte of buffer", page.BufferSize).AppendLine();
2017-12-21 02:03:21 +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
2017-12-21 02:03:21 +00:00
if(page.CurrentSpeed > 0)
sb.AppendFormat("\tDrive's current reading speed is {0} Kbyte/sec.", page.CurrentSpeed).AppendLine();
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
2019-11-25 00:54:38 +00:00
if(page.Method2)
sb.AppendLine("\tDrive supports reading CD-R packet media");
2017-12-21 02:03:21 +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
2019-11-25 00:54:38 +00:00
if(page.ReadDVDROM)
sb.AppendLine("\tDrive can read DVD-ROM");
2017-12-21 02:03:21 +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
2017-12-21 02:03:21 +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
2019-11-25 00:54:38 +00:00
if(page.Composite)
sb.AppendLine("\tDrive can deliver a composite audio and video data stream");
if(page.DigitalPort1)
sb.AppendLine("\tDrive supports IEC-958 digital output on port 1");
if(page.DigitalPort2)
sb.AppendLine("\tDrive supports IEC-958 digital output on port 2");
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
if(page.CurrentWriteSpeedSelected > 0)
{
if(page.RotationControlSelected == 0)
sb.AppendFormat("\tDrive's current writing speed is {0} Kbyte/sec. in CLV mode",
page.CurrentWriteSpeedSelected).AppendLine();
else if(page.RotationControlSelected == 1)
sb.AppendFormat("\tDrive's current writing speed is {0} Kbyte/sec. in pure CAV mode",
page.CurrentWriteSpeedSelected).AppendLine();
}
else
{
if(page.MaxWriteSpeed > 0)
2019-11-25 00:54:38 +00:00
sb.AppendFormat("\tDrive's maximum writing speed is {0} Kbyte/sec.", page.MaxWriteSpeed).
AppendLine();
2017-12-21 02:03:21 +00:00
if(page.CurrentWriteSpeed > 0)
2019-11-25 00:54:38 +00:00
sb.AppendFormat("\tDrive's current writing speed is {0} Kbyte/sec.", page.CurrentWriteSpeed).
AppendLine();
2017-12-21 02:03:21 +00:00
}
if(page.WriteSpeedPerformanceDescriptors != null)
foreach(ModePage_2A_WriteDescriptor descriptor in
page.WriteSpeedPerformanceDescriptors.Where(descriptor => descriptor.WriteSpeed > 0))
if(descriptor.RotationControl == 0)
2019-11-25 00:54:38 +00:00
sb.AppendFormat("\tDrive supports writing at {0} Kbyte/sec. in CLV mode",
descriptor.WriteSpeed).AppendLine();
else if(descriptor.RotationControl == 1)
sb.AppendFormat("\tDrive supports writing at is {0} Kbyte/sec. in pure CAV mode",
descriptor.WriteSpeed).AppendLine();
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
if(page.TestWrite)
sb.AppendLine("\tDrive supports test writing");
if(page.ReadBarcode)
sb.AppendLine("\tDrive can read barcode");
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
if(page.SCC)
sb.AppendLine("\tDrive can read both sides of a disc");
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +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
2019-11-25 00:54:38 +00:00
if(page.CMRSupported == 1)
sb.AppendLine("\tDrive supports DVD CSS and/or DVD CPPM");
2017-12-21 02:03:21 +00:00
2019-11-25 00:54:38 +00:00
if(page.BUF)
sb.AppendLine("\tDrive supports buffer under-run free recording");
2017-12-21 02:03:21 +00:00
return sb.ToString();
}
#endregion Mode Page 0x2A: CD-ROM capabilities page
}
}