1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
4
* Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
6
* Libbrasero-media is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* The Libbrasero-media authors hereby grant permission for non-GPL compatible
12
* GStreamer plugins to be used and distributed together with GStreamer
13
* and Libbrasero-media. This permission is above and beyond the permissions granted
14
* by the GPL license by which Libbrasero-media is covered. If you modify this code
15
* you may extend this exception to your version of the code, but you are not
16
* obligated to do so. If you do not wish to do so, delete this exception
17
* statement from your version.
19
* Libbrasero-media is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU Library General Public License for more details.
24
* You should have received a copy of the GNU General Public License
25
* along with this program; if not, write to:
26
* The Free Software Foundation, Inc.,
27
* 51 Franklin Street, Fifth Floor
28
* Boston, MA 02110-1301, USA.
37
#include "brasero-media-private.h"
39
#include "scsi-error.h"
40
#include "scsi-utils.h"
41
#include "scsi-base.h"
42
#include "scsi-command.h"
43
#include "scsi-opcodes.h"
44
#include "scsi-read-disc-info.h"
46
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
48
struct _BraseroRdDiscInfoCDB {
62
struct _BraseroRdDiscInfoCDB {
76
typedef struct _BraseroRdDiscInfoCDB BraseroRdDiscInfoCDB;
78
BRASERO_SCSI_COMMAND_DEFINE (BraseroRdDiscInfoCDB,
79
READ_DISC_INFORMATION,
83
BRASERO_DISC_INFO_STD = 0x00,
84
BRASERO_DISC_INFO_TRACK_RES = 0x01,
85
BRASERO_DISC_INFO_POW_RES = 0x02,
87
} BraseroDiscInfoType;
91
brasero_mmc1_read_disc_information_std (BraseroDeviceHandle *handle,
92
BraseroScsiDiscInfoStd **info_return,
94
BraseroScsiErrCode *error)
96
BraseroScsiDiscInfoStd std_info;
97
BraseroScsiDiscInfoStd *buffer;
98
BraseroRdDiscInfoCDB *cdb;
99
BraseroScsiResult res;
103
if (!info_return || !size) {
104
BRASERO_SCSI_SET_ERRCODE (error, BRASERO_SCSI_BAD_ARGUMENT);
105
return BRASERO_SCSI_FAILURE;
108
cdb = brasero_scsi_command_new (&info, handle);
109
cdb->data_type = BRASERO_DISC_INFO_STD;
110
BRASERO_SET_16 (cdb->alloc_len, sizeof (BraseroScsiDiscInfoStd));
112
memset (&std_info, 0, sizeof (BraseroScsiDiscInfoStd));
113
res = brasero_scsi_command_issue_sync (cdb,
115
sizeof (BraseroScsiDiscInfoStd),
120
request_size = BRASERO_GET_16 (std_info.len) +
121
sizeof (std_info.len);
123
buffer = (BraseroScsiDiscInfoStd *) g_new0 (uchar, request_size);
125
BRASERO_SET_16 (cdb->alloc_len, request_size);
126
res = brasero_scsi_command_issue_sync (cdb, buffer, request_size, error);
132
buffer_size = BRASERO_GET_16 (buffer->len) +
133
sizeof (buffer->len);
135
if (request_size != buffer_size)
136
BRASERO_MEDIA_LOG ("Sizes mismatch asked %i / received %i",
140
*info_return = buffer;
141
*size = MIN (request_size, buffer_size);
145
brasero_scsi_command_free (cdb);
150
brasero_mmc5_read_disc_information_tracks (BraseroDeviceHandle *handle,
151
BraseroScsiTrackResInfo *info_return,
153
BraseroScsiErrCode *error)
155
BraseroRdDiscInfoCDB *cdb;
156
BraseroScsiResult res;
158
cdb = brasero_scsi_command_new (&info, handle);
159
cdb->data_type = BRASERO_DISC_INFO_TRACK_RES;
160
BRASERO_SET_16 (cdb->alloc_len, size);
162
memset (info_return, 0, size);
163
res = brasero_scsi_command_issue_sync (cdb, info_return, size, error);
164
brasero_scsi_command_free (cdb);
169
brasero_mmc5_read_disc_information_pows (BraseroDeviceHandle *handle,
170
BraseroScsiPOWResInfo *info_return,
172
BraseroScsiErrCode *error)
174
BraseroRdDiscInfoCDB *cdb;
175
BraseroScsiResult res;
177
cdb = brasero_scsi_command_new (&info, handle);
178
cdb->data_type = BRASERO_DISC_INFO_POW_RES;
179
BRASERO_SET_16 (cdb->alloc_len, size);
181
memset (info_return, 0, size);
182
res = brasero_scsi_command_issue_sync (cdb, info_return, size, error);
183
brasero_scsi_command_free (cdb);