Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / wodim / scsi_mmc4.c
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12
13 /* @(#)scsi_mmc4.c      1.1 05/05/16 Copyright 2002-2005 J. Schilling */
14 /*
15  *      SCSI command functions for cdrecord
16  *      covering MMC-4 level and above
17  *
18  *      Copyright (c) 2002-2005 J. Schilling
19  */
20 /*
21  * This program is free software; you can redistribute it and/or modify
22  * it under the terms of the GNU General Public License version 2
23  * as published by the Free Software Foundation.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License along with
31  * this program; see the file COPYING.  If not, write to the Free Software
32  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33  */
34
35 /* #define      DEBUG */
36 #include <mconfig.h>
37
38 #include <stdio.h>
39 #include <standard.h>
40 #include <stdxlib.h>
41 #include <unixstd.h>
42 #include <fctldefs.h>
43 #include <errno.h>
44 #include <strdefs.h>
45 #include <timedefs.h>
46
47 #include <utypes.h>
48 #include <btorder.h>
49 #include <intcvt.h>
50 #include <schily.h>
51
52 #include <usal/usalcmd.h>
53 #include <usal/scsidefs.h>
54 #include <usal/scsireg.h>
55 #include <usal/scsitransp.h>
56
57 #include "scsimmc.h"
58 #include "wodim.h"
59
60  int    get_supported_cdrw_media_types(SCSI *usalp);
61
62 /*
63  * Retrieve list of supported cd-rw media types (feature 0x37)
64  */
65 int
66 get_supported_cdrw_media_types(SCSI *usalp)
67 {
68         Uchar   cbuf[16];
69         int     ret;
70         fillbytes(cbuf, sizeof (cbuf), '\0');
71
72         usalp->silent++;
73         ret = get_configuration(usalp, (char *)cbuf, sizeof (cbuf), 0x37, 2);
74         usalp->silent--;
75
76         if (ret < 0)
77                 return (-1);
78
79         if (cbuf[3] < 12)       /* Couldn't retrieve feature 0x37       */
80                 return (-1);
81
82         return (int)(cbuf[13]);
83 }