libcdio  0.93
mmc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012
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];
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 {
493 #define SCSI_MMC_HAS_DIR_NONE 1
494 
495  typedef struct mmc_subchannel_s
496  {
497  uint8_t reserved;
498  uint8_t audio_status;
499  uint16_t data_length;
500  uint8_t format;
501  uint8_t address: 4;
502  uint8_t control: 4;
503  uint8_t track;
504  uint8_t index;
505  uint8_t abs_addr[4];
506  uint8_t rel_addr[4];
508 
509 #define CDIO_MMC_SET_COMMAND(cdb, command) \
510  cdb[0] = command
511 
512 #define CDIO_MMC_SET_READ_TYPE(cdb, sector_type) \
513  cdb[1] = (sector_type << 2)
514 
515 #define CDIO_MMC_GETPOS_LEN16(p, pos) \
516  (p[pos]<<8) + p[pos+1]
517 
518 #define CDIO_MMC_GET_LEN16(p) \
519  (p[0]<<8) + p[1]
520 
521 #define CDIO_MMC_GET_LEN32(p) \
522  (p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3];
523 
524 #define CDIO_MMC_SET_LEN16(cdb, pos, len) \
525  cdb[pos ] = (len >> 8) & 0xff; \
526  cdb[pos+1] = (len ) & 0xff
527 
528 #define CDIO_MMC_SET_READ_LBA(cdb, lba) \
529  cdb[2] = (lba >> 24) & 0xff; \
530  cdb[3] = (lba >> 16) & 0xff; \
531  cdb[4] = (lba >> 8) & 0xff; \
532  cdb[5] = (lba ) & 0xff
533 
534 #define CDIO_MMC_SET_START_TRACK(cdb, command) \
535  cdb[6] = command
536 
537 #define CDIO_MMC_SET_READ_LENGTH24(cdb, len) \
538  cdb[6] = (len >> 16) & 0xff; \
539  cdb[7] = (len >> 8) & 0xff; \
540  cdb[8] = (len ) & 0xff
541 
542 #define CDIO_MMC_SET_READ_LENGTH16(cdb, len) \
543  CDIO_MMC_SET_LEN16(cdb, 7, len)
544 
545 #define CDIO_MMC_SET_READ_LENGTH8(cdb, len) \
546  cdb[8] = (len ) & 0xff
547 
548 #define CDIO_MMC_MCSB_ALL_HEADERS 0xf
549 
550 #define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(cdb, val) \
551  cdb[9] = val << 3;
552 
562  mmc_audio_volume_t *p_volume);
563 
572  /*out*/ cdio_subchannel_t *p_subchannel);
573 
584  mmc_isrc_track_read_subchannel (CdIo_t *p_cdio,
585  /*in*/ const track_t track,
586  /*out*/ char *p_isrc),
587  "please use mmc_get_track_isrc");
588 
593  const char *mmc_audio_state2str( uint8_t i_audio_state );
594 
601  int mmc_get_blocksize ( CdIo_t *p_cdio );
602 
608  uint8_t mmc_get_cmd_len(uint8_t mmc_cmd);
609 
616  lsn_t mmc_get_disc_last_lsn( const CdIo_t *p_cdio );
617 
627  discmode_t mmc_get_discmode( const CdIo_t *p_cdio );
628 
629 
630  typedef enum {
637 
644 
645 
654  cdio_dvd_struct_t *s);
655 
662  int mmc_get_tray_status ( const CdIo_t *p_cdio );
663 
672  bool mmc_get_hwinfo ( const CdIo_t *p_cdio,
673  /* out*/ cdio_hwinfo_t *p_hw_info );
674 
675 
682  int mmc_get_media_changed(const CdIo_t *p_cdio);
683 
695  char * mmc_get_mcn(const CdIo_t *p_cdio);
696 
709  char * mmc_get_track_isrc(const CdIo_t *p_cdio, track_t i_track);
710 
720  cdio_mmc_feature_interface_t e_interface );
721 
722 
741  driver_return_code_t mmc_read_data_sectors ( CdIo_t *p_cdio, void *p_buf,
742  lsn_t i_lsn,
743  uint16_t i_blocksize,
744  uint32_t i_blocks );
745 
750  driver_return_code_t mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf,
751  lsn_t i_lsn, int read_sector_type,
752  uint32_t i_blocks);
753 
770  mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
771  const mmc_cdb_t *p_cdb,
772  cdio_mmc_direction_t e_direction, unsigned int i_buf,
773  /*in/out*/ void *p_buf );
774 
795  mmc_run_cmd_len( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
796  const mmc_cdb_t *p_cdb, unsigned int i_cdb,
797  cdio_mmc_direction_t e_direction, unsigned int i_buf,
798  /*in/out*/ void *p_buf );
799 
817  int mmc_last_cmd_sense ( const CdIo_t *p_cdio,
818  cdio_mmc_request_sense_t **pp_sense);
819 
824  uint16_t i_blocksize);
825 
833  const char *mmc_cmd2str(uint8_t command);
834 
835 
836 
837 #ifdef __cplusplus
838 }
839 #endif /* __cplusplus */
840 
856 
857 #ifndef DO_NOT_WANT_OLD_MMC_COMPATIBILITY
858 #define CDIO_MMC_GPCMD_START_STOP CDIO_MMC_GPCMD_START_STOP_UNIT
859 #define CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL \
860  CDIO_MMC_GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL
861 #endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
862 
863 #endif /* CDIO_MMC_H_ */
864 
865 /*
866  * Local variables:
867  * c-file-style: "ruby"
868  * tab-width: 8
869  * indent-tabs-mode: nil
870  * End:
871  */
Definition: mmc.h:633
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:501
cdio_mmc_feature_profile_t debug_cdio_mmc_feature_profile
Definition: mmc.h:318
#define PRAGMA_END_PACKED
Definition: types.h:168
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:219
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:265
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:167
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:500
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:275
Definition: mmc.h:279
Definition: mmc.h:424
Definition: mmc.h:404
Definition: mmc.h:207
mmc_audio_volume_entry_t port[4]
Definition: mmc.h:355
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
uint8_t abs_addr[4]
Definition: mmc.h:505
Definition: mmc.h:308
uint8_t track
Definition: mmc.h:503
Definition: mmc.h:161
Definition: mmc.h:259
Definition: mmc.h:324
uint8_t field[MAX_CDB_LEN]
Definition: mmc.h:460
uint8_t control
Definition: mmc.h:502
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:497
Definition: mmc.h:400
Definition: mmc.h:416
uint8_t error_code
Definition: mmc.h:74
Definition: mmc.h:381
uint8_t rel_addr[4]
Definition: mmc.h:506
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:632
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:498
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:631
Definition: mmc.h:203
Definition: mmc.h:171
bool_3way_t
Definition: types.h:235
Definition: mmc.h:495
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:630
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'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:634
mmc_direction_s
Definition: mmc.h:482
Definition: mmc.h:296
Definition: mmc.h:411
Definition: mmc.h:635
Definition: mmc.h:320
discmode_t
Definition: disc.h:36
Definition: mmc.h:304
unsigned char profile_msb
Definition: mmc.h:474
Definition: mmc.h:140
LIBCDIO_DEPRECATED(driver_return_code_t mmc_isrc_track_read_subchannel(CdIo_t *p_cdio, const track_t track, char *p_isrc),"please use mmc_get_track_isrc")
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:499
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:504
cdio_mmc_mode_page_t
Definition: mmc.h:315
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