libcdio
0.83
Main Page
Data Structures
Files
File List
Globals
include
cdio
mmc.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3
Rocky Bernstein <rocky@gnu.org>
4
5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(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 General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
36
#ifndef __CDIO_MMC_H__
37
#define __CDIO_MMC_H__
38
39
#include <
cdio/cdio.h
>
40
#include <
cdio/types.h
>
41
#include <
cdio/dvd.h
>
42
#include <
cdio/audio.h
>
43
#include <
cdio/mmc_util.h
>
44
45
#ifdef __cplusplus
46
extern
"C"
{
47
#endif
/* __cplusplus */
48
49
/* On GNU/Linux see <linux/byteorder/big_endian.h> and
50
<linux/byteorder/little_endian.h>
51
*/
52
#ifdef WORDS_BIGENDIAN
53
# if !defined(__LITTLE_ENDIAN_BITFIELD) && !defined(__BIG_ENDIAN_BITFIELD)
54
# define __MMC_BIG_ENDIAN_BITFIELD
55
# endif
56
#else
57
# if !defined(__LITTLE_ENDIAN_BITFIELD) && !defined(__BIG_ENDIAN_BITFIELD)
58
# define __MMC_LITTLE_ENDIAN_BITFIELD
59
# endif
60
#endif
61
69
typedef
struct
cdio_mmc_request_sense
{
70
#if defined(__MMC_BIG_ENDIAN_BITFIELD)
71
uint8_t
valid
: 1;
72
uint8_t
error_code
: 7;
73
#else
74
uint8_t
error_code
: 7;
75
uint8_t
valid
: 1;
76
#endif
77
uint8_t
segment_number
;
78
#if defined(__MMC_BIG_ENDIAN_BITFIELD)
79
uint8_t
filemark
: 1;
81
uint8_t
eom
: 1;
84
uint8_t
ili
: 1;
85
uint8_t
reserved1
: 1;
86
uint8_t
sense_key
: 4;
87
#else
88
uint8_t
sense_key
: 4;
89
uint8_t
reserved1
: 1;
90
uint8_t
ili
: 1;
91
uint8_t
eom
: 1;
94
uint8_t
filemark
: 1;
96
#endif
97
uint8_t
information
[4];
98
uint8_t
additional_sense_len
;
99
uint8_t
command_info
[4];
100
uint8_t
asc
;
101
uint8_t
ascq
;
102
uint8_t
fruc
;
103
uint8_t
sks
[3];
104
uint8_t
asb
[46];
105
}
cdio_mmc_request_sense_t
;
106
107
111
typedef
enum
{
112
CDIO_MMC_SENSE_KEY_NO_SENSE
= 0,
113
CDIO_MMC_SENSE_KEY_RECOVERED_ERROR
= 1,
114
CDIO_MMC_SENSE_KEY_NOT_READY
= 2,
115
CDIO_MMC_SENSE_KEY_MEDIUM_ERROR
= 3,
116
CDIO_MMC_SENSE_KEY_HARDWARE_ERROR
= 4,
117
CDIO_MMC_SENSE_KEY_ILLEGAL_REQUEST
= 5,
118
CDIO_MMC_SENSE_KEY_UNIT_ATTENTION
= 6,
119
CDIO_MMC_SENSE_KEY_DATA_PROTECT
= 7,
120
CDIO_MMC_SENSE_KEY_BLANK_CHECK
= 8,
121
CDIO_MMC_SENSE_KEY_VENDOR_SPECIFIC
= 9,
122
CDIO_MMC_SENSE_KEY_COPY_ABORTED
= 10,
123
CDIO_MMC_SENSE_KEY_ABORTED_COMMAND
= 11,
124
CDIO_MMC_SENSE_KEY_OBSOLETE
= 12,
125
}
cdio_mmc_sense_key_t
;
126
138
typedef
enum
{
139
CDIO_MMC_GPCMD_TEST_UNIT_READY
= 0x00,
140
CDIO_MMC_GPCMD_INQUIRY
= 0x12,
142
CDIO_MMC_GPCMD_MODE_SELECT_6
= 0x15,
144
CDIO_MMC_GPCMD_MODE_SENSE_6
= 0x1a,
149
CDIO_MMC_GPCMD_START_STOP_UNIT
= 0x1b,
151
CDIO_MMC_GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL
152
= 0x1e,
158
CDIO_MMC_GPCMD_READ_10
= 0x28,
160
CDIO_MMC_GPCMD_READ_SUBCHANNEL
= 0x42,
162
CDIO_MMC_GPCMD_READ_TOC
= 0x43,
164
CDIO_MMC_GPCMD_READ_HEADER
= 0x44,
165
CDIO_MMC_GPCMD_PLAY_AUDIO_10
= 0x45,
168
CDIO_MMC_GPCMD_GET_CONFIGURATION
= 0x46,
170
CDIO_MMC_GPCMD_PLAY_AUDIO_MSF
= 0x47,
173
CDIO_MMC_GPCMD_PLAY_AUDIO_TI
= 0x48,
174
CDIO_MMC_GPCMD_PLAY_TRACK_REL_10
= 0x49,
181
CDIO_MMC_GPCMD_GET_EVENT_STATUS
= 0x4a,
183
CDIO_MMC_GPCMD_PAUSE_RESUME
= 0x4b,
187
CDIO_MMC_GPCMD_READ_DISC_INFO
= 0x51,
189
CDIO_MMC_GPCMD_READ_TRACK_INFORMATION
= 0x52,
191
CDIO_MMC_GPCMD_MODE_SELECT_10
= 0x55,
193
CDIO_MMC_GPCMD_MODE_SENSE_10
= 0x5a,
202
CDIO_MMC_GPCMD_PLAY_AUDIO_12
= 0xa5,
205
CDIO_MMC_GPCMD_LOAD_UNLOAD
= 0xa6,
207
CDIO_MMC_GPCMD_READ_12
= 0xa8,
209
CDIO_MMC_GPCMD_PLAY_TRACK_REL_12
= 0xa9,
215
CDIO_MMC_GPCMD_READ_DVD_STRUCTURE
= 0xad,
217
CDIO_MMC_GPCMD_READ_MSF
= 0xb9,
220
CDIO_MMC_GPCMD_SET_SPEED
= 0xbb,
230
CDIO_MMC_GPCMD_READ_CD
= 0xbe,
236
CDIO_MMC_GPCMD_CD_PLAYBACK_STATUS
= 0xc4 ,
237
CDIO_MMC_GPCMD_PLAYBACK_CONTROL
= 0xc9 ,
238
CDIO_MMC_GPCMD_READ_CDDA
= 0xd8 ,
239
CDIO_MMC_GPCMD_READ_CDXA
= 0xdb ,
240
CDIO_MMC_GPCMD_READ_ALL_SUBCODES
= 0xdf
241
}
cdio_mmc_gpcmd_t
;
242
243
247
typedef
enum
{
248
CDIO_MMC_READ_SUB_ST_INVALID
= 0x00,
249
CDIO_MMC_READ_SUB_ST_PLAY
= 0x11,
251
CDIO_MMC_READ_SUB_ST_PAUSED
= 0x12,
252
CDIO_MMC_READ_SUB_ST_COMPLETED
= 0x13,
254
CDIO_MMC_READ_SUB_ST_ERROR
= 0x14,
256
CDIO_MMC_READ_SUB_ST_NO_STATUS
= 0x15,
258
}
cdio_mmc_read_sub_state_t
;
259
261
typedef
enum
{
262
CDIO_MMC_READ_TYPE_ANY
= 0,
263
CDIO_MMC_READ_TYPE_CDDA
= 1,
264
CDIO_MMC_READ_TYPE_MODE1
= 2,
265
CDIO_MMC_READ_TYPE_MODE2
= 3,
266
CDIO_MMC_READ_TYPE_M2F1
= 4,
267
CDIO_MMC_READ_TYPE_M2F2
= 5
268
}
cdio_mmc_read_cd_type_t
;
269
273
typedef
enum
{
274
CDIO_MMC_READTOC_FMT_TOC
= 0,
275
CDIO_MMC_READTOC_FMT_SESSION
= 1,
276
CDIO_MMC_READTOC_FMT_FULTOC
= 2,
277
CDIO_MMC_READTOC_FMT_PMA
= 3,
278
CDIO_MMC_READTOC_FMT_ATIP
= 4,
279
CDIO_MMC_READTOC_FMT_CDTEXT
= 5
280
}
cdio_mmc_readtoc_t
;
281
285
typedef
enum
{
286
CDIO_MMC_R_W_ERROR_PAGE
= 0x01,
287
CDIO_MMC_WRITE_PARMS_PAGE
= 0x05,
288
CDIO_MMC_CDR_PARMS_PAGE
= 0x0d,
289
CDIO_MMC_AUDIO_CTL_PAGE
= 0x0e,
290
CDIO_MMC_POWER_PAGE
= 0x1a,
291
CDIO_MMC_FAULT_FAIL_PAGE
= 0x1c,
292
CDIO_MMC_TO_PROTECT_PAGE
= 0x1d,
293
CDIO_MMC_CAPABILITIES_PAGE
= 0x2a,
294
CDIO_MMC_ALL_PAGES
= 0x3f,
295
}
cdio_mmc_mode_page_t
;
296
300
typedef
enum
{
301
CDIO_MMC_READ_DISC_INFO_STANDARD
= 0x0,
302
CDIO_MMC_READ_DISC_INFO_TRACK
= 0x1,
303
CDIO_MMC_READ_DISC_INFO_POW
= 0x2,
304
}
cdio_mmc_read_disc_info_datatype_t
;
305
306
307
PRAGMA_BEGIN_PACKED
308
struct
mmc_audio_volume_entry_s
309
{
310
uint8_t
selection
;
/* Only the lower 4 bits are used. */
311
uint8_t
volume
;
312
}
GNUC_PACKED
;
313
314
typedef
struct
mmc_audio_volume_entry_s
mmc_audio_volume_entry_t
;
315
319
struct
mmc_audio_volume_s
320
{
321
mmc_audio_volume_entry_t
port
[4];
322
}
GNUC_PACKED
;
323
324
typedef
struct
mmc_audio_volume_s
mmc_audio_volume_t
;
325
326
PRAGMA_END_PACKED
327
328
332
typedef
enum
{
333
CDIO_MMC_GET_CONF_ALL_FEATURES
= 0,
335
CDIO_MMC_GET_CONF_CURRENT_FEATURES
= 1,
338
CDIO_MMC_GET_CONF_NAMED_FEATURE
= 2
340
}
cdio_mmc_get_conf_t
;
341
342
347
typedef
enum
{
348
CDIO_MMC_FEATURE_PROFILE_LIST
= 0x000,
349
CDIO_MMC_FEATURE_CORE
= 0x001,
350
CDIO_MMC_FEATURE_MORPHING
= 0x002,
352
CDIO_MMC_FEATURE_REMOVABLE_MEDIUM
= 0x003,
353
CDIO_MMC_FEATURE_WRITE_PROTECT
= 0x004,
354
CDIO_MMC_FEATURE_RANDOM_READABLE
= 0x010,
355
CDIO_MMC_FEATURE_MULTI_READ
= 0x01D,
356
CDIO_MMC_FEATURE_CD_READ
= 0x01E,
357
CDIO_MMC_FEATURE_DVD_READ
= 0x01F,
358
CDIO_MMC_FEATURE_RANDOM_WRITABLE
= 0x020,
359
CDIO_MMC_FEATURE_INCR_WRITE
= 0x021,
361
CDIO_MMC_FEATURE_SECTOR_ERASE
= 0x022,
362
CDIO_MMC_FEATURE_FORMATABLE
= 0x023,
363
CDIO_MMC_FEATURE_DEFECT_MGMT
= 0x024,
367
CDIO_MMC_FEATURE_WRITE_ONCE
= 0x025,
369
CDIO_MMC_FEATURE_RESTRICT_OVERW
= 0x026,
371
CDIO_MMC_FEATURE_CD_RW_CAV
= 0x027,
372
CDIO_MMC_FEATURE_MRW
= 0x028,
373
CDIO_MMC_FEATURE_ENHANCED_DEFECT
= 0x029,
374
CDIO_MMC_FEATURE_DVD_PRW
= 0x02A,
375
CDIO_MMC_FEATURE_DVD_PR
= 0x02B,
376
CDIO_MMC_FEATURE_RIGID_RES_OVERW
= 0x02C,
377
CDIO_MMC_FEATURE_CD_TAO
= 0x02D,
378
CDIO_MMC_FEATURE_CD_SAO
= 0x02E,
380
CDIO_MMC_FEATURE_DVD_R_RW_WRITE
= 0x02F,
381
CDIO_MMC_FEATURE_CD_RW_MEDIA_WRITE
= 0x037,
382
CDIO_MMC_FEATURE_DVD_PR_2_LAYER
= 0x03B,
383
CDIO_MMC_FEATURE_POWER_MGMT
= 0x100,
385
CDIO_MMC_FEATURE_CDDA_EXT_PLAY
= 0x103,
388
CDIO_MMC_FEATURE_MCODE_UPGRADE
= 0x104,
/* Ability for the device to
389
accept new microcode via
390
the interface */
391
CDIO_MMC_FEATURE_TIME_OUT
= 0x105,
394
CDIO_MMC_FEATURE_DVD_CSS
= 0x106,
397
CDIO_MMC_FEATURE_RT_STREAMING
= 0x107,
400
CDIO_MMC_FEATURE_LU_SN
= 0x108,
402
CDIO_MMC_FEATURE_FIRMWARE_DATE
= 0x1FF,
404
}
cdio_mmc_feature_t
;
405
406
typedef
enum
{
407
CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED
= 0,
408
CDIO_MMC_FEATURE_INTERFACE_SCSI
= 1,
409
CDIO_MMC_FEATURE_INTERFACE_ATAPI
= 2,
410
CDIO_MMC_FEATURE_INTERFACE_IEEE_1394
= 3,
411
CDIO_MMC_FEATURE_INTERFACE_IEEE_1394A
= 4,
412
CDIO_MMC_FEATURE_INTERFACE_FIBRE_CH
= 5
413
}
cdio_mmc_feature_interface_t
;
414
415
420
#define MAX_CDB_LEN 12
421
426
typedef
struct
mmc_cdb_s
{
427
uint8_t
field
[
MAX_CDB_LEN
];
428
}
mmc_cdb_t
;
429
434
typedef
struct
mmc_feature_list_header_s
{
435
unsigned
char
length_msb
;
436
unsigned
char
length_1sb
;
437
unsigned
char
length_2sb
;
438
unsigned
char
length_lsb
;
439
unsigned
char
reserved1
;
440
unsigned
char
reserved2
;
441
unsigned
char
profile_msb
;
442
unsigned
char
profile_lsb
;
443
}
cdio_mmc_feature_list_header_t
;
444
449
typedef
enum
mmc_direction_s
{
450
SCSI_MMC_DATA_READ
,
451
SCSI_MMC_DATA_WRITE
,
452
SCSI_MMC_DATA_NONE
453
}
cdio_mmc_direction_t
;
460
#define SCSI_MMC_HAS_DIR_NONE 1
461
462
typedef
struct
mmc_subchannel_s
463
{
464
uint8_t
reserved
;
465
uint8_t
audio_status
;
466
uint16_t
data_length
;
467
uint8_t
format
;
468
uint8_t
address
: 4;
469
uint8_t
control
: 4;
470
uint8_t
track
;
471
uint8_t
index
;
472
uint8_t
abs_addr
[4];
473
uint8_t
rel_addr
[4];
474
}
cdio_mmc_subchannel_t
;
475
476
#define CDIO_MMC_SET_COMMAND(cdb, command) \
477
cdb[0] = command
478
479
#define CDIO_MMC_SET_READ_TYPE(cdb, sector_type) \
480
cdb[1] = (sector_type << 2)
481
482
#define CDIO_MMC_GETPOS_LEN16(p, pos) \
483
(p[pos]<<8) + p[pos+1]
484
485
#define CDIO_MMC_GET_LEN16(p) \
486
(p[0]<<8) + p[1]
487
488
#define CDIO_MMC_GET_LEN32(p) \
489
(p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3];
490
491
#define CDIO_MMC_SET_LEN16(cdb, pos, len) \
492
cdb[pos ] = (len >> 8) & 0xff; \
493
cdb[pos+1] = (len ) & 0xff
494
495
#define CDIO_MMC_SET_READ_LBA(cdb, lba) \
496
cdb[2] = (lba >> 24) & 0xff; \
497
cdb[3] = (lba >> 16) & 0xff; \
498
cdb[4] = (lba >> 8) & 0xff; \
499
cdb[5] = (lba ) & 0xff
500
501
#define CDIO_MMC_SET_START_TRACK(cdb, command) \
502
cdb[6] = command
503
504
#define CDIO_MMC_SET_READ_LENGTH24(cdb, len) \
505
cdb[6] = (len >> 16) & 0xff; \
506
cdb[7] = (len >> 8) & 0xff; \
507
cdb[8] = (len ) & 0xff
508
509
#define CDIO_MMC_SET_READ_LENGTH16(cdb, len) \
510
CDIO_MMC_SET_LEN16(cdb, 7, len)
511
512
#define CDIO_MMC_SET_READ_LENGTH8(cdb, len) \
513
cdb[8] = (len ) & 0xff
514
515
#define CDIO_MMC_MCSB_ALL_HEADERS 0xf
516
517
#define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(cdb, val) \
518
cdb[9] = val << 3;
519
528
driver_return_code_t
mmc_audio_get_volume
(
CdIo_t
*p_cdio,
/*out*/
529
mmc_audio_volume_t
*p_volume);
530
537
driver_return_code_t
538
mmc_audio_read_subchannel
(
CdIo_t
*p_cdio,
539
/*out*/
cdio_subchannel_t
*p_subchannel);
540
550
driver_return_code_t
551
mmc_isrc_track_read_subchannel
(
CdIo_t
*p_cdio,
/*in*/
const
track_t
track,
552
/*out*/
char
*p_isrc);
553
558
const
char
*
mmc_audio_state2str
( uint8_t i_audio_state );
559
566
int
mmc_get_blocksize
(
CdIo_t
*p_cdio );
567
573
uint8_t
mmc_get_cmd_len
(uint8_t mmc_cmd);
574
581
lsn_t
mmc_get_disc_last_lsn
(
const
CdIo_t
*p_cdio );
582
592
discmode_t
mmc_get_discmode
(
const
CdIo_t
*p_cdio );
593
594
595
typedef
enum
{
596
CDIO_MMC_LEVEL_WEIRD
,
597
CDIO_MMC_LEVEL_1
,
598
CDIO_MMC_LEVEL_2
,
599
CDIO_MMC_LEVEL_3
,
600
CDIO_MMC_LEVEL_NONE
601
}
cdio_mmc_level_t
;
602
608
cdio_mmc_level_t
mmc_get_drive_mmc_cap
(
CdIo_t
*p_cdio);
609
610
618
discmode_t
mmc_get_dvd_struct_physical
(
const
CdIo_t
*p_cdio,
619
cdio_dvd_struct_t
*s);
620
627
int
mmc_get_tray_status
(
const
CdIo_t
*p_cdio );
628
637
bool
mmc_get_hwinfo
(
const
CdIo_t
*p_cdio,
638
/* out*/
cdio_hwinfo_t
*p_hw_info );
639
640
647
int
mmc_get_media_changed
(
const
CdIo_t
*p_cdio);
648
660
char
*
mmc_get_mcn
(
const
CdIo_t
*p_cdio);
661
670
bool_3way_t
mmc_have_interface
(
CdIo_t
*p_cdio,
671
cdio_mmc_feature_interface_t
e_interface );
672
673
692
driver_return_code_t
mmc_read_data_sectors
(
CdIo_t
*p_cdio,
void
*p_buf,
693
lsn_t
i_lsn,
694
uint16_t i_blocksize,
695
uint32_t i_blocks );
696
701
driver_return_code_t
mmc_read_sectors
(
const
CdIo_t
*p_cdio,
void
*p_buf,
702
lsn_t
i_lsn,
int
read_sector_type,
703
uint32_t i_blocks);
704
720
driver_return_code_t
721
mmc_run_cmd
(
const
CdIo_t
*p_cdio,
unsigned
int
i_timeout_ms,
722
const
mmc_cdb_t
*p_cdb,
723
cdio_mmc_direction_t
e_direction,
unsigned
int
i_buf,
724
/*in/out*/
void
*p_buf );
725
745
driver_return_code_t
746
mmc_run_cmd_len
(
const
CdIo_t
*p_cdio,
unsigned
int
i_timeout_ms,
747
const
mmc_cdb_t
*p_cdb,
unsigned
int
i_cdb,
748
cdio_mmc_direction_t
e_direction,
unsigned
int
i_buf,
749
/*in/out*/
void
*p_buf );
750
768
int
mmc_last_cmd_sense
(
const
CdIo_t
*p_cdio,
769
cdio_mmc_request_sense_t
**pp_sense);
770
774
driver_return_code_t
mmc_set_blocksize
(
const
CdIo_t
*p_cdio,
775
uint16_t i_blocksize);
776
777
#ifdef __cplusplus
778
}
779
#endif
/* __cplusplus */
780
787
extern
cdio_mmc_feature_t
debug_cdio_mmc_feature
;
788
extern
cdio_mmc_feature_interface_t
debug_cdio_mmc_feature_interface
;
789
extern
cdio_mmc_feature_profile_t
debug_cdio_mmc_feature_profile
;
790
extern
cdio_mmc_get_conf_t
debug_cdio_mmc_get_conf
;
791
extern
cdio_mmc_gpcmd_t
debug_cdio_mmc_gpcmd
;
792
extern
cdio_mmc_read_sub_state_t
debug_cdio_mmc_read_sub_state
;
793
extern
cdio_mmc_read_cd_type_t
debug_cdio_mmc_read_cd_type
;
794
extern
cdio_mmc_readtoc_t
debug_cdio_mmc_readtoc
;
795
extern
cdio_mmc_mode_page_t
debug_cdio_mmc_mode_page
;
796
797
#ifndef DO_NOT_WANT_OLD_MMC_COMPATIBILITY
798
#define CDIO_MMC_GPCMD_START_STOP CDIO_MMC_GPCMD_START_STOP_UNIT
799
#define CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL \
800
CDIO_MMC_GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL
801
#endif
/*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
802
803
#endif
/* __MMC_H__ */
804
805
/*
806
* Local variables:
807
* c-file-style: "ruby"
808
* tab-width: 8
809
* indent-tabs-mode: nil
810
* End:
811
*/
Generated for libcdio by
1.8.1.1