forgotten commit. disabled until egl is adapted.
[AROS-Contrib.git] / FryingPan / Optical / Disc_DVD_MinusRW.cpp
blob99471a920bc472c4b9488a2cae5f45ef41a80a02
1 /*
2 * FryingPan - Amiga CD/DVD Recording Software (User Interface and supporting Libraries only)
3 * Copyright (C) 2001-2011 Tomasz Wiszkowski Tomasz.Wiszkowski at gmail.com
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "Headers.h"
21 #include "Disc_DVD_MinusRW.h"
23 Disc_DVD_MinusRW::Disc_DVD_MinusRW(Drive *d) : Disc_DVD_MinusR(d)
25 meas = 0;
26 readfmtcaps = 0;
29 void Disc_DVD_MinusRW::Init(void)
31 Disc_DVD_MinusR::Init(); // MUSI BYC W TEJ KOLEJNOSCI
32 readfmtcaps = new cmd_ReadFormatCapacities(dio);
33 readfmtcaps->Go();
36 Disc_DVD_MinusRW::~Disc_DVD_MinusRW(void)
38 delete readfmtcaps;
41 bool Disc_DVD_MinusRW::IsFormatted(void)
43 if (NULL == readfmtcaps)
44 return false;
45 if (readfmtcaps->IsFormatted())
46 return true;
47 return false;
50 bool Disc_DVD_MinusRW::IsOverwritable(void)
52 cmd_GetConfiguration::Feature *x;
54 if (DiscType() != DRT_Profile_DVD_MinusRW_Restricted)
55 return 0;
57 x = drive->GetDriveFeature(cmd_GetConfiguration::Feature_RigidOverwrite);
58 if (x)
59 if (x->IsCurrent()) return 1;
61 x = drive->GetDriveFeature(cmd_GetConfiguration::Feature_RestrictedOverwrite);
62 if (x)
63 if (x->IsCurrent()) return 1;
65 return 0;
68 int Disc_DVD_MinusRW::EraseDisc(int met)
70 cmd_Blank::BlankType type;
71 int err;
72 cmd_StartStopUnit ssu(dio);
74 ssu.setType(cmd_StartStopUnit::StartStop_Start);
75 ssu.Go();
78 Page<Page_Write> &pw = drive->GetWritePage();
79 pw->SetWriteType(Page_Write::WriteType_SessionAtOnce);
80 if (drive->SetPage(pw))
81 return ODE_CommandError;
83 switch (met) {
84 case DRT_Blank_Complete:
86 type = cmd_Blank::Blank_All;
87 meas = drive->GetHardwareConfig()->DVDMinusInfo()->getCBlankMeas(GetDiscSize(), GetWriteSpeed());
89 break;
90 case DRT_Blank_Fast:
92 type = cmd_Blank::Blank_Minimal;
93 meas = drive->GetHardwareConfig()->DVDMinusInfo()->getQBlankMeas(GetDiscSize(), GetWriteSpeed());
95 break;
96 default:
97 return ODE_IllegalParameter;
100 Calibrate();
102 cmd_Blank *blk = new cmd_Blank(dio);
103 blk->setType(type, 0);
104 blk->setImmediate(true);
106 if (meas != 0)
107 meas->begin();
108 err = blk->Go();
109 WaitOpComplete();
110 if (meas != 0)
111 meas->end();
112 meas = 0;
113 // if (err == ODE_OK) Init();
114 RequestUpdate();
115 delete blk;
116 return err;
119 int Disc_DVD_MinusRW::FormatDisc(int met)
121 cmd_Format *fmt;
122 int err;
123 cmd_StartStopUnit ssu(dio);
125 ssu.setType(cmd_StartStopUnit::StartStop_Start);
126 ssu.Go();
128 Page<Page_Write> &pw = drive->GetWritePage();
129 pw->SetWriteType(Page_Write::WriteType_Packet);
130 pw->SetPacketSize(16);
131 if (drive->SetPage(pw))
132 return ODE_CommandError;
134 Calibrate();
136 fmt = new cmd_Format(dio);
137 fmt->setImmediate(true);
139 switch (met)
141 case DRT_Format_Complete:
143 _D(Lvl_Info, "Complete format of dvd-rw media requested");
144 fmt->setType(cmd_Format::Format_FullFormat, readfmtcaps->GetMaxCapacity(), 16);
145 meas = drive->GetHardwareConfig()->DVDMinusInfo()->getCFormatMeas(GetDiscSize(), GetWriteSpeed());
147 break;
148 case DRT_Format_Fast:
150 _D(Lvl_Info, "Quick format of dvd-rw media requested");
151 fmt->setType(cmd_Format::Format_DVDM_QuickFormat, 0, 16);
152 meas = drive->GetHardwareConfig()->DVDMinusInfo()->getQFormatMeas(GetDiscSize(), GetWriteSpeed());
154 break;
157 if (meas != 0)
158 meas->begin();
159 err = fmt->Go();
160 WaitOpComplete();
161 if (meas != 0)
162 meas->end();
163 meas = 0;
164 // if (err == ODE_OK) Init();
165 RequestUpdate();
166 delete fmt;
167 return err;
170 int Disc_DVD_MinusRW::StructureDisc(void)
172 int err;
173 err = EraseDisc(DRT_Blank_Fast);
174 if (err) return err;
175 err = FormatDisc(DRT_Format_Fast);
176 if (err) return err;
177 return ODE_OK;
180 int Disc_DVD_MinusRW::DiscType()
182 if (NULL == readfmtcaps)
183 return DRT_Profile_DVD_MinusRW_Sequential; // we dont know if it can be formatted
185 if (readfmtcaps->IsFormatted()) {
186 return DRT_Profile_DVD_MinusRW_Restricted;
187 } else {
188 return DRT_Profile_DVD_MinusRW_Sequential;
192 bool Disc_DVD_MinusRW::IsWritable()
194 // _D("Checking whether disc is formatted...");
195 // if (!IsFormatted())
196 // return false;
197 _D(Lvl_Info, "Checking for writable tracks...");
198 if (GetNextWritableTrack(0))
199 return true;
200 return false;
203 int16 Disc_DVD_MinusRW::GetOperationProgress()
205 if (meas != 0)
207 return meas->getProgress();
209 return Disc::GetOperationProgress();
212 uint32 Disc_DVD_MinusRW::GetDiscSize()
214 if (0 != readfmtcaps)
215 return readfmtcaps->GetMaxCapacity();
216 return Disc_DVD_MinusR::GetDiscSize();