示例#1
0
/**
  Request information about et drive capabilities vis SCSI-MMC READ
  DISC INFORMATION
  
  @param p_cdio the CD object to be acted upon.

  @param p_buf pointer to location to store mode sense information
  
  @param i_size number of bytes allocated to p_buf
   
  @param data_type kind of information to retrieve.

  @return DRIVER_OP_SUCCESS (0) if we got the status.
 */
driver_return_code_t 
mmc_read_disc_information(const CdIo_t *p_cdio, /*out*/ void *p_buf,
			  unsigned int i_size, 
			  cdio_mmc_read_disc_info_datatype_t data_type,
			  unsigned int i_timeout_ms)
{
    MMC_CMD_SETUP(CDIO_MMC_GPCMD_READ_DISC_INFO);
    CDIO_MMC_SET_READ_LENGTH8(cdb.field, i_size);
    if (0 == i_timeout_ms) i_timeout_ms = mmc_timeout_ms;
    cdb.field[1] = data_type & 0x7;
    return MMC_RUN_CMD(SCSI_MMC_DATA_READ, i_timeout_ms);
}
示例#2
0
/**
  Get drive capabilities vis SCSI-MMC GET CONFIGURATION
  @param p_cdio the CD object to be acted upon.
  @return DRIVER_OP_SUCCESS (0) if we got the status.
  return codes are the same as driver_return_code_t
*/
driver_return_code_t 
mmc_get_configuration(const CdIo_t *p_cdio, void *p_buf, 
		      unsigned int i_size, 
		      unsigned int return_type, 
		      unsigned int i_starting_feature_number,
		      unsigned int i_timeout_ms)

{
    MMC_CMD_SETUP(CDIO_MMC_GPCMD_GET_CONFIGURATION);
    CDIO_MMC_SET_READ_LENGTH8(cdb.field, i_size);
    if (0 == i_timeout_ms) i_timeout_ms = mmc_timeout_ms;
    cdb.field[1] = return_type & 0x3;
    CDIO_MMC_SET_LEN16(cdb.field, 2, i_starting_feature_number);
    return MMC_RUN_CMD(SCSI_MMC_DATA_READ, i_timeout_ms);
}
示例#3
0
/**
   Issue a READ SUB-CHANNEL command to read current position, ISRC or
   MCN from subchannel Q.
   Note: READ SUB-CHANNEL is deprecated as of MMC-5
         but the alternative requires manual parsing of the subchannel.

   @param p_cdio  the CD object to be acted upon.
   @param i_track track number (only for ISRC)
   @param sub_chan_param 2 for MCN, 3 for ISRC
   @param i_length pointer to number of bytes to request. 
                   Will be overwritten by the number of bytes available.
   @param p_buf  pointer to the location for the returned data

   @return DRIVER_OP_SUCCESS on success
 */
driver_return_code_t
mmc_read_subchannel ( const CdIo_t *p_cdio,
                             track_t i_track,
                             unsigned char sub_chan_param,
                             unsigned int *i_length,
                             char *p_buf,
                             unsigned int i_timeout_ms
                            )
{
  unsigned int i_size = *i_length;
  mmc_cdb_t cdb = {{0, }};
  driver_return_code_t i_status;

  if (i_size < 4)
    return DRIVER_OP_BAD_PARAMETER;

  CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_READ_SUBCHANNEL);
  CDIO_MMC_SET_READ_LENGTH8(cdb.field, i_size);

  if(CDIO_SUBCHANNEL_CURRENT_POSITION == sub_chan_param)
    cdb.field[1] = CDIO_CDROM_MSF;
  else
    cdb.field[1] = 0x0;
  cdb.field[2] = 0x40;
  cdb.field[3] = sub_chan_param;
  if(CDIO_SUBCHANNEL_TRACK_ISRC == sub_chan_param)
   cdb.field[6] = i_track;
  else
   cdb.field[6] = 0;

  memset(p_buf, 0, i_size);

  if (0 == i_timeout_ms) i_timeout_ms = mmc_timeout_ms;

  i_status = MMC_RUN_CMD(SCSI_MMC_DATA_READ, i_timeout_ms);

  if(i_status == DRIVER_OP_SUCCESS) {
    *i_length = CDIO_MMC_GET_LEN16((p_buf+2)) + 4;
  }
  return i_status;
}
示例#4
0
文件: mmc2.cpp 项目: flyingtime/boxee
int
main(int argc, const char *argv[])
{
  CdIo_t *p_cdio;

  p_cdio = cdio_open (NULL, DRIVER_UNKNOWN);

  if (NULL == p_cdio) {
    printf("Couldn't find CD\n");
    return 1;
  } else {
    int i_status;              /* Result of MMC command */
    uint8_t buf[500] = { 0, }; /* Place to hold returned data */
    mmc_cdb_t cdb = {{0, }};   /* Command Descriptor Buffer */

    CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_GET_CONFIGURATION);
    CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf));
    cdb.field[1] = CDIO_MMC_GET_CONF_ALL_FEATURES;
    cdb.field[3] = 0x0;

    i_status = mmc_run_cmd(p_cdio, 0, &cdb, SCSI_MMC_DATA_READ, sizeof(buf), 
			   &buf);
    if (i_status == 0) {
      uint8_t *p;
      uint32_t i_data;
      uint8_t *p_max = buf + 65530;

      i_data = (unsigned int) CDIO_MMC_GET_LEN32(buf);
      /* set to first sense feature code, and then walk through the masks */
      p = buf + 8;
      while( (p < &(buf[i_data])) && (p < p_max) ) {
	uint16_t i_feature;
	uint8_t i_feature_additional = p[3];
	
	i_feature = CDIO_MMC_GET_LEN16(p);
	{
	  uint8_t *q;
	  const char *feature_str = mmc_feature2str(i_feature);
	  printf("%s Feature\n", feature_str);
	  switch( i_feature )
	    {
	    case CDIO_MMC_FEATURE_PROFILE_LIST:
	      for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) {
		int i_profile=CDIO_MMC_GET_LEN16(q);
		const char *feature_profile_str = 
		  mmc_feature_profile2str(i_profile);
		printf( "\t%s", feature_profile_str );
		if (q[2] & 1) {
		  printf(" - on");
		}
		printf("\n");
	      }
	      printf("\n");
	    
	      break;
	    case CDIO_MMC_FEATURE_CORE: 
	      {
		uint8_t *q = p+4;
		uint32_t 	i_interface_standard = CDIO_MMC_GET_LEN32(q);
		switch(i_interface_standard) {
		case 0: 
		  printf("\tunspecified interface\n");
		  break;
		case 1: 
		  printf("\tSCSI interface\n");
		  break;
		case 2: 
		  printf("\tATAPI interface\n");
		  break;
		case 3: 
		  printf("\tIEEE 1394 interface\n");
		  break;
		case 4:
		  printf("\tIEEE 1394A interface\n");
		  break;
		case 5:
		  printf("\tFibre Channel interface\n");
		}
		printf("\n");
		break;
	      }
	    case CDIO_MMC_FEATURE_REMOVABLE_MEDIUM:
	      switch(p[4] >> 5) {
	      case 0:
		printf("\tCaddy/Slot type loading mechanism\n");
		break;
	      case 1:
		printf("\tTray type loading mechanism\n");
		break;
	      case 2:
		printf("\tPop-up type loading mechanism\n");
		break;
	      case 4:
		printf("\tEmbedded changer with individually changeable discs\n");
		break;
	      case 5:
		printf("\tEmbedded changer using a magazine mechanism\n");
		break;
	      default:
		printf("\tUnknown changer mechanism\n");
	      }
	      
	      printf("\tcan%s eject the medium or magazine via the normal "
		     "START/STOP command\n", 
		     (p[4] & 8) ? "": "not");
	      printf("\tcan%s be locked into the Logical Unit\n", 
		     (p[4] & 1) ? "": "not");
	      printf("\n");
	      break;
	    case CDIO_MMC_FEATURE_CD_READ:
	      printf("CD Read Feature\n");
	      printf("\tC2 Error pointers are %ssupported\n", 
		     (p[4] & 2) ? "": "not ");
	      printf("\tCD-Text is %ssupported\n", 
		     (p[4] & 1) ? "": "not ");
	      printf("\n");
	      break;
	    case CDIO_MMC_FEATURE_CDDA_EXT_PLAY:
	      printf("\tSCAN command is %ssupported\n", 
		     (p[4] & 4) ? "": "not ");
	      printf("\taudio channels can %sbe muted separately\n", 
		     (p[4] & 2) ? "": "not ");
	      printf("\taudio channels can %shave separate volume levels\n", 
		     (p[4] & 1) ? "": "not ");
	      {
		uint8_t *q = p+6;
		uint16_t i_vol_levels = CDIO_MMC_GET_LEN16(q);
		printf("\t%d volume levels can be set\n", i_vol_levels);
	      }
	      printf("\n");
	      break;
	    case CDIO_MMC_FEATURE_LU_SN: {
	      uint8_t i_serial = *(p+3);
	      char serial[257] = { '\0', };
	      memcpy(serial, p+4, i_serial);
	      printf("\t%s\n\n", serial);
	      break;
	    }
	    default: 
	      printf("\n");
	      break;
	    }
	  p += i_feature_additional + 4;
	}
      }
    } else {