Merge branch 'master' into 'master'
[brasero.git] / libbrasero-media / scsi-mode-select.c
blob4fb9f2150799844f3a2d84dd9001c6acb0e44a64
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /*
3 * Libbrasero-media
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.
31 #ifdef HAVE_CONFIG_H
32 # include <config.h>
33 #endif
35 #include <glib.h>
37 #include "scsi-spc1.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-mode-pages.h"
46 /**
47 * MODE SELECT command description (defined in SPC, Scsi Primary Commands)
50 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
52 struct _BraseroModeSelectCDB {
53 uchar opcode :8;
55 uchar SP :1;
56 uchar reserved0 :3;
57 uchar PF :1;
58 uchar reserved1 :3;
60 uchar reserved2 [5];
62 uchar alloc_len [2];
63 uchar ctl;
66 #else
68 struct _BraseroModeSelectCDB {
69 uchar opcode :8;
71 uchar reserved0 :3;
72 uchar PF :1;
73 uchar reserved1 :3;
74 uchar SP :1;
76 uchar reserved2 [5];
78 uchar alloc_len [2];
79 uchar ctl;
82 #endif
84 typedef struct _BraseroModeSelectCDB BraseroModeSelectCDB;
86 BRASERO_SCSI_COMMAND_DEFINE (BraseroModeSelectCDB,
87 MODE_SELECT,
88 BRASERO_SCSI_WRITE);
90 #define BRASERO_MODE_DATA(data) ((BraseroScsiModeData *) (data))
92 BraseroScsiResult
93 brasero_spc1_mode_select (BraseroDeviceHandle *handle,
94 BraseroScsiModeData *data,
95 int size,
96 BraseroScsiErrCode *error)
98 BraseroModeSelectCDB *cdb;
99 BraseroScsiResult res;
101 g_return_val_if_fail (handle != NULL, BRASERO_SCSI_FAILURE);
103 cdb = brasero_scsi_command_new (&info, handle);
104 cdb->PF = 1;
105 cdb->SP = 0;
107 /* Header pages lengths should be 0 */
108 // BRASERO_SET_16 (data->hdr.len, 0);
109 // BRASERO_SET_16 (data->hdr.bdlen, 0);
111 BRASERO_SET_16 (cdb->alloc_len, size);
112 res = brasero_scsi_command_issue_sync (cdb, data, size, error);
113 brasero_scsi_command_free (cdb);
115 return res;