libcdio  0.90
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, /*in*/ const track_t track,
585  /*out*/ char *p_isrc);
586 
591  const char *mmc_audio_state2str( uint8_t i_audio_state );
592 
599  int mmc_get_blocksize ( CdIo_t *p_cdio );
600 
606  uint8_t mmc_get_cmd_len(uint8_t mmc_cmd);
607 
614  lsn_t mmc_get_disc_last_lsn( const CdIo_t *p_cdio );
615 
625  discmode_t mmc_get_discmode( const CdIo_t *p_cdio );
626 
627 
628  typedef enum {
635 
642 
643 
652  cdio_dvd_struct_t *s);
653 
660  int mmc_get_tray_status ( const CdIo_t *p_cdio );
661 
670  bool mmc_get_hwinfo ( const CdIo_t *p_cdio,
671  /* out*/ cdio_hwinfo_t *p_hw_info );
672 
673 
680  int mmc_get_media_changed(const CdIo_t *p_cdio);
681 
693  char * mmc_get_mcn(const CdIo_t *p_cdio);
694 
704  cdio_mmc_feature_interface_t e_interface );
705 
706 
725  driver_return_code_t mmc_read_data_sectors ( CdIo_t *p_cdio, void *p_buf,
726  lsn_t i_lsn,
727  uint16_t i_blocksize,
728  uint32_t i_blocks );
729 
734  driver_return_code_t mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf,
735  lsn_t i_lsn, int read_sector_type,
736  uint32_t i_blocks);
737 
754  mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
755  const mmc_cdb_t *p_cdb,
756  cdio_mmc_direction_t e_direction, unsigned int i_buf,
757  /*in/out*/ void *p_buf );
758 
779  mmc_run_cmd_len( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
780  const mmc_cdb_t *p_cdb, unsigned int i_cdb,
781  cdio_mmc_direction_t e_direction, unsigned int i_buf,
782  /*in/out*/ void *p_buf );
783 
801  int mmc_last_cmd_sense ( const CdIo_t *p_cdio,
802  cdio_mmc_request_sense_t **pp_sense);
803 
808  uint16_t i_blocksize);
809 
817  const char *mmc_cmd2str(uint8_t command);
818 
819 
820 
821 #ifdef __cplusplus
822 }
823 #endif /* __cplusplus */
824 
840 
841 #ifndef DO_NOT_WANT_OLD_MMC_COMPATIBILITY
842 #define CDIO_MMC_GPCMD_START_STOP CDIO_MMC_GPCMD_START_STOP_UNIT
843 #define CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL \
844  CDIO_MMC_GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL
845 #endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
846 
847 #endif /* CDIO_MMC_H_ */
848 
849 /*
850  * Local variables:
851  * c-file-style: "ruby"
852  * tab-width: 8
853  * indent-tabs-mode: nil
854  * End:
855  */

Generated for libcdio by doxygen 1.8.3.1