libcdio  0.83
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];
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 {
152  = 0x1e,
242 
243 
247  typedef enum {
259 
261  typedef enum {
269 
273  typedef enum {
281 
285  typedef enum {
296 
300  typedef enum {
305 
306 
309  {
310  uint8_t selection; /* Only the lower 4 bits are used. */
311  uint8_t volume;
312  } GNUC_PACKED;
313 
315 
320  {
322  } GNUC_PACKED;
323 
325 
327 
328 
332 typedef enum {
341 
342 
347 typedef enum {
388  CDIO_MMC_FEATURE_MCODE_UPGRADE = 0x104, /* Ability for the device to
389  accept new microcode via
390  the interface */
405 
406 typedef enum {
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;
444 
449  typedef enum mmc_direction_s {
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];
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 
529  mmc_audio_volume_t *p_volume);
530 
539  /*out*/ cdio_subchannel_t *p_subchannel);
540 
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 {
602 
609 
610 
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 
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 
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 
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 
775  uint16_t i_blocksize);
776 
777 #ifdef __cplusplus
778 }
779 #endif /* __cplusplus */
780 
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 doxygen 1.8.1.1