libcdio  2.1.0
mmc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012
3  2016, 2019 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];
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];
106 
107 
111  typedef enum {
126 
138  typedef enum {
154  = 0x1e,
216 
273 
277  typedef enum {
289 
291  typedef enum {
299 
303  typedef enum {
311 
315  typedef enum {
326 
330  typedef enum {
335 
336 /* For backward compatibility. */
337 #define CDIO_MMC_GPCMD_READ_DISC_INFO CDIO_MMC_GPCMD_READ_DISC_INFORMATION
338 #define CDIO_MMC_GPCMD_READ_DISC_STRUCTURE CDIO_MMC_GPMD_READ_DVD_STRUCTURE
339 
340 
343  {
344  uint8_t selection; /* Only the lower 4 bits are used. */
345  uint8_t volume;
346  } GNUC_PACKED;
347 
349 
354  {
356  } GNUC_PACKED;
357 
359 
361 
362 
366 typedef enum {
375 
376 
380 typedef enum {
421  CDIO_MMC_FEATURE_MCODE_UPGRADE = 0x104, /* Ability for the device to
422  accept new microcode via
423  the interface */
438 
439 typedef enum {
447 
448 
453 #define MAX_CDB_LEN 12
454 
459 typedef struct mmc_cdb_s {
460  uint8_t field[MAX_CDB_LEN];
461 } mmc_cdb_t;
462 
467  typedef struct mmc_feature_list_header_s {
468  unsigned char length_msb;
469  unsigned char length_1sb;
470  unsigned char length_2sb;
471  unsigned char length_lsb;
472  unsigned char reserved1;
473  unsigned char reserved2;
474  unsigned char profile_msb;
475  unsigned char profile_lsb;
477 
482  typedef enum mmc_direction_s {
494 #define SCSI_MMC_HAS_DIR_NONE 1
495 
496  typedef struct mmc_subchannel_s
497  {
498  uint8_t reserved;
499  uint8_t audio_status;
500  uint16_t data_length;
501  uint8_t format;
502  uint8_t address: 4;
503  uint8_t control: 4;
504  uint8_t track;
505  uint8_t index;
506  uint8_t abs_addr[4];
507  uint8_t rel_addr[4];
509 
510 #define CDIO_MMC_SET_COMMAND(cdb, command) \
511  cdb[0] = command
512 
513 #define CDIO_MMC_SET_READ_TYPE(cdb, sector_type) \
514  cdb[1] = (sector_type << 2)
515 
516 #define CDIO_MMC_GETPOS_LEN16(p, pos) \
517  (p[pos]<<8) + p[pos+1]
518 
519 #define CDIO_MMC_GET_LEN16(p) \
520  (p[0]<<8) + p[1]
521 
522 #define CDIO_MMC_GET_LEN32(p) \
523  (p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3];
524 
525 #define CDIO_MMC_SET_LEN16(cdb, pos, len) \
526  cdb[pos ] = (len >> 8) & 0xff; \
527  cdb[pos+1] = (len ) & 0xff
528 
529 #define CDIO_MMC_SET_READ_LBA(cdb, lba) \
530  cdb[2] = (lba >> 24) & 0xff; \
531  cdb[3] = (lba >> 16) & 0xff; \
532  cdb[4] = (lba >> 8) & 0xff; \
533  cdb[5] = (lba ) & 0xff
534 
535 #define CDIO_MMC_SET_START_TRACK(cdb, command) \
536  cdb[6] = command
537 
538 #define CDIO_MMC_SET_READ_LENGTH24(cdb, len) \
539  cdb[6] = (len >> 16) & 0xff; \
540  cdb[7] = (len >> 8) & 0xff; \
541  cdb[8] = (len ) & 0xff
542 
543 #define CDIO_MMC_SET_READ_LENGTH16(cdb, len) \
544  CDIO_MMC_SET_LEN16(cdb, 7, len)
545 
546 #define CDIO_MMC_SET_READ_LENGTH8(cdb, len) \
547  cdb[8] = (len ) & 0xff
548 
549 #define CDIO_MMC_MCSB_ALL_HEADERS 0xf
550 
551 #define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(cdb, val) \
552  cdb[9] = val << 3;
553 
563  mmc_audio_volume_t *p_volume);
564 
573  /*out*/ cdio_subchannel_t *p_subchannel);
574 
579  const char *mmc_audio_state2str( uint8_t i_audio_state );
580 
587  int mmc_get_blocksize ( CdIo_t *p_cdio );
588 
594  uint8_t mmc_get_cmd_len(uint8_t mmc_cmd);
595 
602  lsn_t mmc_get_disc_last_lsn( const CdIo_t *p_cdio );
603 
613  discmode_t mmc_get_discmode( const CdIo_t *p_cdio );
614 
615 
616  typedef enum {
623 
629  cdio_mmc_level_t mmc_get_drive_mmc_cap(CdIo_t *p_cdio);
630 
631 
640  cdio_dvd_struct_t *s);
641 
648  int mmc_get_tray_status ( const CdIo_t *p_cdio );
649 
658  bool mmc_get_hwinfo ( const CdIo_t *p_cdio,
659  /* out*/ cdio_hwinfo_t *p_hw_info );
660 
661 
668  int mmc_get_media_changed(const CdIo_t *p_cdio);
669 
681  char * mmc_get_mcn(const CdIo_t *p_cdio);
682 
695  char * mmc_get_track_isrc(const CdIo_t *p_cdio, track_t i_track);
696 
728  uint8_t * mmc_read_cdtext (const CdIo_t *p_cdio);
729 
739  cdio_mmc_feature_interface_t e_interface );
740 
741 
760  driver_return_code_t mmc_read_data_sectors ( CdIo_t *p_cdio, void *p_buf,
761  lsn_t i_lsn,
762  uint16_t i_blocksize,
763  uint32_t i_blocks );
764 
769  driver_return_code_t mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf,
770  lsn_t i_lsn, int read_sector_type,
771  uint32_t i_blocks);
772 
789  mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
790  const mmc_cdb_t *p_cdb,
791  cdio_mmc_direction_t e_direction, unsigned int i_buf,
792  /*in/out*/ void *p_buf );
793 
814  mmc_run_cmd_len( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
815  const mmc_cdb_t *p_cdb, unsigned int i_cdb,
816  cdio_mmc_direction_t e_direction, unsigned int i_buf,
817  /*in/out*/ void *p_buf );
818 
836  int mmc_last_cmd_sense ( const CdIo_t *p_cdio,
837  cdio_mmc_request_sense_t **pp_sense);
838 
843  uint16_t i_blocksize);
844 
852  const char *mmc_cmd2str(uint8_t command);
853 
854 
855 
856 #ifdef __cplusplus
857 }
858 #endif /* __cplusplus */
859 
875 
876 #ifndef DO_NOT_WANT_OLD_MMC_COMPATIBILITY
877 #define CDIO_MMC_GPCMD_START_STOP CDIO_MMC_GPCMD_START_STOP_UNIT
878 #define CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL \
879  CDIO_MMC_GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL
880 #endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
881 
882 #endif /* CDIO_MMC_H_ */
883 
884 /*
885  * Local variables:
886  * c-file-style: "ruby"
887  * tab-width: 8
888  * indent-tabs-mode: nil
889  * End:
890  */
Definition: mmc.h:619
Definition: mmc.h:170
uint8_t fruc
Definition: mmc.h:102
Definition: mmc.h:193
Definition: mmc.h:172
Definition: mmc.h:228
The top-level header for CD audio-related libcdio calls. These control playing of the CD-ROM through ...
Definitions for DVD access.
Definition: mmc.h:322
uint8_t asc
Definition: mmc.h:100
cdio_mmc_feature_interface_t
Definition: mmc.h:439
#define MAX_CDB_LEN
Definition: mmc.h:453
unsigned char reserved2
Definition: mmc.h:473
Definition: mmc.h:383
char * mmc_get_mcn(const CdIo_t *p_cdio)
Definition: mmc.h:306
Common type definitions used pervasively in libcdio.
Definition: mmc.h:294
driver_return_code_t mmc_read_data_sectors(CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, uint16_t i_blocksize, uint32_t i_blocks)
uint8_t address
Definition: mmc.h:502
cdio_mmc_feature_profile_t debug_cdio_mmc_feature_profile
Definition: mmc.h:318
#define PRAGMA_END_PACKED
Definition: types.h:169
uint8_t selection
Definition: mmc.h:344
unsigned char reserved1
Definition: mmc.h:472
lsn_t mmc_get_disc_last_lsn(const CdIo_t *p_cdio)
cdio_mmc_feature_t
Definition: mmc.h:380
Definition: mmc.h:405
Definition: mmc.h:295
Definition: mmc.h:174
driver_return_code_t
Definition: device.h:205
Definition: mmc.h:427
Definition: mmc.h:120
Definition: mmc.h:307
cdio_mmc_level_t mmc_get_drive_mmc_cap(CdIo_t *p_cdio)
Definition: mmc.h:441
Definition: mmc.h:223
driver_return_code_t mmc_audio_get_volume(CdIo_t *p_cdio, mmc_audio_volume_t *p_volume)
Definition: mmc.h:413
Definition: mmc.h:282
Definition: mmc.h:321
Definition: mmc.h:269
uint8_t information[4]
Definition: mmc.h:97
cdio_mmc_get_conf_t
Definition: mmc.h:366
Definition: mmc.h:164
struct mmc_feature_list_header_s cdio_mmc_feature_list_header_t
Format of header block in data returned from an MMC GET_CONFIGURATION command.
Definition: dvd.h:122
Definition: mmc.h:231
int32_t lsn_t
Definition: types.h:266
Definition: mmc.h:208
Definition: mmc.h:177
Definition: mmc.h:142
char * mmc_get_track_isrc(const CdIo_t *p_cdio, track_t i_track)
uint8_t segment_number
Definition: mmc.h:77
unsigned char length_lsb
Definition: mmc.h:471
Definition: mmc.h:268
#define PRAGMA_BEGIN_PACKED
Definition: types.h:168
driver_return_code_t mmc_audio_read_subchannel(CdIo_t *p_cdio, cdio_subchannel_t *p_subchannel)
int mmc_last_cmd_sense(const CdIo_t *p_cdio, cdio_mmc_request_sense_t **pp_sense)
unsigned char length_1sb
Definition: mmc.h:469
Definition: mmc.h:389
Definition: mmc.h:195
Definition: mmc.h:278
Definition: mmc.h:124
uint8_t format
Definition: mmc.h:501
int mmc_get_blocksize(CdIo_t *p_cdio)
cdio_mmc_feature_profile_t
Definition: mmc_util.h:36
cdio_mmc_read_cd_type_t debug_cdio_mmc_read_cd_type
Definition: mmc.h:144
uint8_t track_t
Definition: types.h:276
Definition: mmc.h:279
Definition: mmc.h:424
Definition: mmc.h:404
Definition: mmc.h:207
Definition: mmc.h:284
Definition: mmc.h:119
Definition: mmc.h:292
unsigned char length_msb
Definition: mmc.h:468
Definition: mmc.h:319
uint8_t sense_key
Definition: mmc.h:88
Definition: mmc.h:114
cdio_mmc_sense_key_t
Definition: mmc.h:111
uint8_t asb[46]
Definition: mmc.h:104
struct cdio_mmc_request_sense cdio_mmc_request_sense_t
cdio_mmc_read_sub_state_t debug_cdio_mmc_read_sub_state
Definition: mmc.h:407
int mmc_get_media_changed(const CdIo_t *p_cdio)
Definition: mmc.h:421
Definition: mmc.h:308
uint8_t track
Definition: mmc.h:504
Definition: mmc.h:161
Definition: mmc.h:259
Definition: mmc.h:324
uint8_t control
Definition: mmc.h:503
enum mmc_direction_s cdio_mmc_direction_t
const char * mmc_cmd2str(uint8_t command)
Definition: mmc.h:122
Definition: mmc.h:162
Definition: mmc.h:390
Definition: mmc.h:185
Definition: mmc.h:230
Definition: mmc.h:146
uint8_t reserved
Definition: mmc.h:498
Definition: mmc.h:400
Definition: mmc.h:416
uint8_t error_code
Definition: mmc.h:74
Definition: mmc.h:381
cdio_mmc_read_disc_info_datatype_t
Definition: mmc.h:330
cdio_mmc_readtoc_t
Definition: mmc.h:303
cdio_mmc_mode_page_t debug_cdio_mmc_mode_page
Definition: mmc.h:305
Definition: mmc.h:367
Definition: mmc.h:410
Definition: mmc.h:281
driver_return_code_t mmc_read_sectors(const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn, int read_sector_type, uint32_t i_blocks)
Definition: mmc.h:293
uint8_t filemark
Definition: mmc.h:94
cdio_mmc_gpcmd_t debug_cdio_mmc_gpcmd
cdio_mmc_read_sub_state_t
Definition: mmc.h:277
uint8_t eom
Definition: mmc.h:91
Definition: mmc.h:115
Definition: mmc.h:139
struct mmc_cdb_s mmc_cdb_t
A Command Descriptor Block (CDB) used in sending MMC commands.
cdio_mmc_read_cd_type_t
Definition: mmc.h:291
Definition: mmc.h:386
Definition: mmc.h:165
Definition: mmc.h:220
Definition: mmc.h:483
The top-level header for libcdio: the CD Input and Control library. Applications include this for any...
Definition: mmc.h:430
Definition: mmc.h:168
Definition: mmc.h:618
uint8_t ili
Definition: mmc.h:90
Definition: mmc.h:433
Definition: mmc.h:297
Definition: mmc.h:332
Definition: mmc.h:241
Definition: mmc.h:342
struct mmc_subchannel_s cdio_mmc_subchannel_t
Definition: mmc.h:245
Definition: mmc.h:485
Definition: mmc.h:205
Definition: mmc.h:112
uint8_t reserved1
Definition: mmc.h:89
Definition: mmc.h:151
Definition: mmc.h:260
driver_return_code_t mmc_set_blocksize(const CdIo_t *p_cdio, uint16_t i_blocksize)
Definition: mmc.h:396
Definition: mmc.h:215
Definition: mmc.h:333
int mmc_get_tray_status(const CdIo_t *p_cdio)
uint8_t command_info[4]
Definition: mmc.h:99
Definition: mmc.h:239
driver_return_code_t mmc_run_cmd_len(const CdIo_t *p_cdio, unsigned int i_timeout_ms, const mmc_cdb_t *p_cdb, unsigned int i_cdb, cdio_mmc_direction_t e_direction, unsigned int i_buf, void *p_buf)
Structure to return CD vendor, model, and revision-level strings obtained via the INQUIRY command...
Definition: device.h:122
cdio_mmc_feature_interface_t debug_cdio_mmc_feature_interface
struct _CdIo CdIo_t
Definition: cdio.h:47
Definition: mmc.h:316
Definition: mmc.h:415
Definition: mmc.h:395
unsigned char profile_lsb
Definition: mmc.h:475
Definition: mmc.h:435
uint8_t audio_status
Definition: mmc.h:499
driver_return_code_t mmc_run_cmd(const CdIo_t *p_cdio, unsigned int i_timeout_ms, const mmc_cdb_t *p_cdb, cdio_mmc_direction_t e_direction, unsigned int i_buf, void *p_buf)
uint8_t volume
Definition: mmc.h:345
uint8_t ascq
Definition: mmc.h:101
Definition: mmc.h:484
A Command Descriptor Block (CDB) used in sending MMC commands.
Definition: mmc.h:459
unsigned char length_2sb
Definition: mmc.h:470
const char * mmc_audio_state2str(uint8_t i_audio_state)
Definition: mmc.h:353
Definition: mmc.h:617
Definition: mmc.h:203
Definition: mmc.h:171
bool_3way_t
Definition: types.h:236
Definition: mmc.h:496
uint8_t sks[3]
Definition: mmc.h:103
cdio_mmc_get_conf_t debug_cdio_mmc_get_conf
Definition: mmc.h:270
Definition: mmc.h:408
Definition: mmc.h:392
cdio_mmc_level_t
Definition: mmc.h:616
Definition: mmc.h:418
Definition: mmc.h:317
Definition: mmc.h:388
bool mmc_get_hwinfo(const CdIo_t *p_cdio, cdio_hwinfo_t *p_hw_info)
Definition: mmc.h:249
PRAGMA_BEGIN_PACKED struct mmc_audio_volume_entry_s GNUC_PACKED
Definition: mmc.h:372
Definition: mmc.h:141
Definition: mmc.h:309
Definition: mmc.h:225
Definition: mmc.h:182
Multimedia Command (MMC) "helper" routines that don&#39;t depend on anything other than headers...
Definition: mmc.h:286
Definition: mmc.h:394
Definition: mmc.h:382
Definition: mmc.h:224
Definition: mmc.h:620
mmc_direction_s
Definition: mmc.h:482
Definition: mmc.h:296
Definition: mmc.h:411
Definition: mmc.h:621
Definition: mmc.h:320
discmode_t
Definition: disc.h:37
Definition: mmc.h:304
unsigned char profile_msb
Definition: mmc.h:474
Definition: mmc.h:140
discmode_t mmc_get_discmode(const CdIo_t *p_cdio)
Definition: audio.h:34
uint8_t mmc_get_cmd_len(uint8_t mmc_cmd)
Definition: mmc.h:69
discmode_t mmc_get_dvd_struct_physical(const CdIo_t *p_cdio, cdio_dvd_struct_t *s)
uint16_t data_length
Definition: mmc.h:500
uint8_t valid
Definition: mmc.h:75
uint8_t additional_sense_len
Definition: mmc.h:98
cdio_mmc_gpcmd_t
The opcode-portion (generic packet commands) of an MMC command.
Definition: mmc.h:138
Definition: mmc.h:402
Definition: mmc.h:176
uint8_t index
Definition: mmc.h:505
cdio_mmc_mode_page_t
Definition: mmc.h:315
uint8_t * mmc_read_cdtext(const CdIo_t *p_cdio)
cdio_mmc_feature_t debug_cdio_mmc_feature
Definition: mmc.h:221
Definition: mmc.h:166
Definition: mmc.h:246
bool_3way_t mmc_have_interface(CdIo_t *p_cdio, cdio_mmc_feature_interface_t e_interface)
cdio_mmc_readtoc_t debug_cdio_mmc_readtoc
Definition: mmc.h:323
Format of header block in data returned from an MMC GET_CONFIGURATION command.
Definition: mmc.h:467