Files
Aaru/Aaru.Decoders/SCSI/Modes/2A.cs

300 lines
11 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-12-03 16:07:08 +00:00
// Copyright © 2011-2023 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;
2020-02-27 00:33:24 +00:00
using Aaru.CommonTypes.Structs.Devices.SCSI.Modes;
2017-12-21 02:03:21 +00:00
namespace Aaru.Decoders.SCSI;
2023-10-03 23:09:28 +01:00
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
2022-03-06 13:29:37 +00:00
public static partial class Modes
2017-12-21 02:03:21 +00:00
{
2023-10-03 23:09:28 +01:00
#region Mode Page 0x2A: CD-ROM capabilities page
2022-03-06 13:29:37 +00:00
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
var sb = new StringBuilder();
2017-12-21 02:03:21 +00:00
sb.AppendLine(Localization.SCSI_CD_ROM_capabilities_page);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.PS)
sb.AppendLine("\t" + Localization.Parameters_can_be_saved);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.AudioPlay)
sb.AppendLine("\t" + Localization.Drive_can_play_audio);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.Mode2Form1)
sb.AppendLine("\t" + Localization.Drive_can_read_sectors_in_Mode_2_Form_1_format);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.Mode2Form2)
sb.AppendLine("\t" + Localization.Drive_can_read_sectors_in_Mode_2_Form_2_format);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.MultiSession)
sb.AppendLine("\t" + Localization.Drive_supports_multi_session_discs_and_or_Photo_CD);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.CDDACommand)
sb.AppendLine("\t" + Localization.Drive_can_read_digital_audio);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.AccurateCDDA)
sb.AppendLine("\t" + Localization.Drive_can_continue_from_streaming_loss);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.Subchannel)
sb.AppendLine("\t" + Localization.Drive_can_read_uncorrected_and_interleaved_R_W_subchannels);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.DeinterlaveSubchannel)
sb.AppendLine("\t" + Localization.Drive_can_read__deinterleave_and_correct_R_W_subchannels);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.C2Pointer)
sb.AppendLine("\t" + Localization.Drive_supports_C2_pointers);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.UPC)
sb.AppendLine("\t" + Localization.Drive_can_read_Media_Catalogue_Number);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.ISRC)
sb.AppendLine("\t" + Localization.Drive_can_read_ISRC);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
switch(modePage.LoadingMechanism)
2022-03-06 13:29:37 +00:00
{
case 0:
sb.AppendLine("\t" + Localization.Drive_uses_media_caddy);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
case 1:
sb.AppendLine("\t" + Localization.Drive_uses_a_tray);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
case 2:
sb.AppendLine("\t" + Localization.Drive_is_pop_up);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
case 4:
sb.AppendLine("\t" + Localization.Drive_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("\t" + Localization.Drive_is_a_changer_using_cartridges);
2019-11-25 00:54:38 +00:00
2022-03-06 13:29:37 +00:00
break;
default:
sb.AppendFormat("\t" + Localization.Drive_uses_unknown_loading_mechanism_type__0_,
modePage.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-11-15 00:20:20 +00:00
if(modePage.Lock)
sb.AppendLine("\t" + Localization.Drive_can_lock_media);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.PreventJumper)
2022-03-06 13:29:37 +00:00
{
sb.AppendLine("\t" + Localization.Drive_power_ups_locked);
2019-11-25 00:54:38 +00:00
2023-10-03 23:09:28 +01:00
sb.AppendLine(modePage.LockState
? "\t" + Localization.Drive_is_locked__media_cannot_be_ejected_or_inserted
: "\t" + Localization.Drive_is_not_locked__media_can_be_ejected_and_inserted);
2022-03-06 13:29:37 +00:00
}
else
2023-10-03 23:09:28 +01:00
{
2022-11-15 00:20:20 +00:00
sb.AppendLine(modePage.LockState
? "\t" +
Localization.Drive_is_locked__media_cannot_be_ejected__but_if_empty__can_be_inserted
: "\t" + Localization.Drive_is_not_locked__media_can_be_ejected_and_inserted);
2023-10-03 23:09:28 +01:00
}
2018-06-22 08:08:38 +01:00
2022-11-15 00:20:20 +00:00
if(modePage.Eject)
sb.AppendLine("\t" + Localization.Drive_can_eject_media);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.SeparateChannelMute)
sb.AppendLine("\t" + Localization.Each_channel_can_be_muted_independently);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.SeparateChannelVolume)
sb.AppendLine("\t" + Localization.Each_channel_s_volume_can_be_controlled_independently);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.SupportedVolumeLevels > 0)
2023-10-03 23:09:28 +01:00
{
sb.AppendFormat("\t" + Localization.Drive_supports_0_volume_levels, modePage.SupportedVolumeLevels).
AppendLine();
2023-10-03 23:09:28 +01:00
}
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.BufferSize > 0)
sb.AppendFormat("\t" + Localization.Drive_has_0_Kbyte_of_buffer, modePage.BufferSize).AppendLine();
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.MaximumSpeed > 0)
2023-10-03 23:09:28 +01:00
{
sb.AppendFormat("\t" + Localization.Drive_maximum_reading_speed_is_0_Kbyte_sec, modePage.MaximumSpeed).
AppendLine();
2023-10-03 23:09:28 +01:00
}
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.CurrentSpeed > 0)
2023-10-03 23:09:28 +01:00
{
sb.AppendFormat("\t" + Localization.Drive_current_reading_speed_is_0_Kbyte_sec, modePage.CurrentSpeed).
AppendLine();
2023-10-03 23:09:28 +01:00
}
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.ReadCDR)
2022-03-06 13:29:37 +00:00
{
2023-10-03 23:09:28 +01:00
sb.AppendLine(modePage.WriteCDR
? "\t" + Localization.Drive_can_read_and_write_CD_R
: "\t" + Localization.Drive_can_read_CD_R);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.Method2)
sb.AppendLine("\t" + Localization.Drive_supports_reading_CD_R_packet_media);
2022-03-06 13:29:37 +00:00
}
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.ReadCDRW)
2023-10-03 23:09:28 +01:00
{
sb.AppendLine(modePage.WriteCDRW
? "\t" + Localization.Drive_can_read_and_write_CD_RW
: "\t" + Localization.Drive_can_read_CD_RW);
}
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.ReadDVDROM)
sb.AppendLine("\t" + Localization.Drive_can_read_DVD_ROM);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.ReadDVDR)
2023-10-03 23:09:28 +01:00
{
sb.AppendLine(modePage.WriteDVDR
? "\t" + Localization.Drive_can_read_and_write_DVD_R
: "\t" + Localization.Drive_can_read_DVD_R);
}
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.ReadDVDRAM)
2023-10-03 23:09:28 +01:00
{
sb.AppendLine(modePage.WriteDVDRAM
? "\t" + Localization.Drive_can_read_and_write_DVD_RAM
: "\t" + Localization.Drive_can_read_DVD_RAM);
}
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.Composite)
sb.AppendLine("\t" + Localization.Drive_can_deliver_a_composite_audio_and_video_data_stream);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.DigitalPort1)
sb.AppendLine("\t" + Localization.Drive_supports_IEC_958_digital_output_on_port_1);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.DigitalPort2)
sb.AppendLine("\t" + Localization.Drive_supports_IEC_958_digital_output_on_port_2);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.SDP)
sb.AppendLine("\t" + Localization.Drive_contains_a_changer_that_can_report_the_exact_contents_of_the_slots);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.CurrentWriteSpeedSelected > 0)
2023-10-03 23:09:28 +01:00
{
2022-11-15 00:20:20 +00:00
switch(modePage.RotationControlSelected)
2022-11-13 19:38:02 +00:00
{
case 0:
sb.AppendFormat("\t" + Localization.Drive_current_writing_speed_is_0_Kbyte_sec_in_CLV_mode,
modePage.CurrentWriteSpeedSelected).
AppendLine();
2022-11-13 19:38:02 +00:00
break;
case 1:
sb.AppendFormat("\t" + Localization.Drive_current_writing_speed_is_0_Kbyte_sec_in_pure_CAV_mode,
modePage.CurrentWriteSpeedSelected).
AppendLine();
2022-11-13 19:38:02 +00:00
break;
}
2023-10-03 23:09:28 +01:00
}
2022-03-06 13:29:37 +00:00
else
{
2022-11-15 00:20:20 +00:00
if(modePage.MaxWriteSpeed > 0)
2023-10-03 23:09:28 +01:00
{
sb.AppendFormat("\t" + Localization.Drive_maximum_writing_speed_is_0_Kbyte_sec, modePage.MaxWriteSpeed).
2022-11-15 00:20:20 +00:00
AppendLine();
2023-10-03 23:09:28 +01:00
}
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.CurrentWriteSpeed > 0)
2023-10-03 23:09:28 +01:00
{
sb.AppendFormat("\t" + Localization.Drive_current_writing_speed_is_0_Kbyte_sec,
modePage.CurrentWriteSpeed).
AppendLine();
2023-10-03 23:09:28 +01:00
}
2022-03-06 13:29:37 +00:00
}
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.WriteSpeedPerformanceDescriptors != null)
2023-10-03 23:09:28 +01:00
{
2022-11-15 00:20:20 +00:00
foreach(ModePage_2A_WriteDescriptor descriptor in
modePage.WriteSpeedPerformanceDescriptors.Where(descriptor => descriptor.WriteSpeed > 0))
2023-10-03 23:09:28 +01:00
{
2022-11-13 19:38:02 +00:00
switch(descriptor.RotationControl)
{
case 0:
sb.AppendFormat("\t" + Localization.Drive_supports_writing_at_0_Kbyte_sec_in_CLV_mode,
descriptor.WriteSpeed).
AppendLine();
2022-11-13 19:38:02 +00:00
break;
case 1:
sb.AppendFormat("\t" + Localization.Drive_supports_writing_at_is_0_Kbyte_sec_in_pure_CAV_mode,
descriptor.WriteSpeed).
AppendLine();
2022-11-13 19:38:02 +00:00
break;
}
2023-10-03 23:09:28 +01:00
}
}
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.TestWrite)
sb.AppendLine("\t" + Localization.Drive_supports_test_writing);
2019-11-25 00:54:38 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.ReadBarcode)
sb.AppendLine("\t" + Localization.Drive_can_read_barcode);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.SCC)
sb.AppendLine("\t" + Localization.Drive_can_read_both_sides_of_a_disc);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.LeadInPW)
sb.AppendLine("\t" + Localization.Drive_an_read_raw_R_W_subchannel_from_the_Lead_In);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.CMRSupported == 1)
sb.AppendLine("\t" + Localization.Drive_supports_DVD_CSS_and_or_DVD_CPPM);
2017-12-21 02:03:21 +00:00
2022-11-15 00:20:20 +00:00
if(modePage.BUF)
sb.AppendLine("\t" + Localization.Drive_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
}
2023-10-03 23:09:28 +01:00
#endregion Mode Page 0x2A: CD-ROM capabilities page
2017-12-21 02:03:21 +00:00
}