return 0;
}
+static void feature_profile_media(struct udev *udev, int cur_profile)
+{
+ switch (cur_profile) {
+ case 0x03:
+ case 0x04:
+ case 0x05:
+ info(udev, "profile 0x%02x \n", cur_profile);
+ cd_media = 1;
+ cd_media_mo = 1;
+ break;
+ case 0x08:
+ info(udev, "profile 0x%02x media_cd_rom\n", cur_profile);
+ cd_media = 1;
+ cd_media_cd_rom = 1;
+ break;
+ case 0x09:
+ info(udev, "profile 0x%02x media_cd_r\n", cur_profile);
+ cd_media = 1;
+ cd_media_cd_r = 1;
+ break;
+ case 0x0a:
+ info(udev, "profile 0x%02x media_cd_rw\n", cur_profile);
+ cd_media = 1;
+ cd_media_cd_rw = 1;
+ break;
+ case 0x10:
+ info(udev, "profile 0x%02x media_dvd_ro\n", cur_profile);
+ cd_media = 1;
+ cd_media_dvd_rom = 1;
+ break;
+ case 0x11:
+ info(udev, "profile 0x%02x media_dvd_r\n", cur_profile);
+ cd_media = 1;
+ cd_media_dvd_r = 1;
+ break;
+ case 0x12:
+ info(udev, "profile 0x%02x media_dvd_ram\n", cur_profile);
+ cd_media = 1;
+ cd_media_dvd_ram = 1;
+ break;
+ case 0x13:
+ info(udev, "profile 0x%02x media_dvd_rw_ro\n", cur_profile);
+ cd_media = 1;
+ cd_media_dvd_rw = 1;
+ cd_media_dvd_rw_ro = 1;
+ break;
+ case 0x14:
+ info(udev, "profile 0x%02x media_dvd_rw_seq\n", cur_profile);
+ cd_media = 1;
+ cd_media_dvd_rw = 1;
+ cd_media_dvd_rw_seq = 1;
+ break;
+ case 0x1B:
+ info(udev, "profile 0x%02x media_dvd_plus_r\n", cur_profile);
+ cd_media = 1;
+ cd_media_dvd_plus_r = 1;
+ break;
+ case 0x1A:
+ info(udev, "profile 0x%02x media_dvd_plus_rw\n", cur_profile);
+ cd_media = 1;
+ cd_media_dvd_plus_rw = 1;
+ break;
+ case 0x2A:
+ info(udev, "profile 0x%02x media_dvd_plus_rw_dl\n", cur_profile);
+ cd_media = 1;
+ cd_media_dvd_plus_rw_dl = 1;
+ break;
+ case 0x2B:
+ info(udev, "profile 0x%02x media_dvd_plus_r_dl\n", cur_profile);
+ cd_media = 1;
+ cd_media_dvd_plus_r_dl = 1;
+ break;
+ case 0x40:
+ info(udev, "profile 0x%02x media_bd\n", cur_profile);
+ cd_media = 1;
+ cd_media_bd = 1;
+ break;
+ case 0x41:
+ case 0x42:
+ info(udev, "profile 0x%02x media_bd_r\n", cur_profile);
+ cd_media = 1;
+ cd_media_bd_r = 1;
+ break;
+ case 0x43:
+ info(udev, "profile 0x%02x media_bd_re\n", cur_profile);
+ cd_media = 1;
+ cd_media_bd_re = 1;
+ break;
+ case 0x50:
+ info(udev, "profile 0x%02x media_hddvd\n", cur_profile);
+ cd_media = 1;
+ cd_media_hddvd = 1;
+ break;
+ case 0x51:
+ info(udev, "profile 0x%02x media_hddvd_r\n", cur_profile);
+ cd_media = 1;
+ cd_media_hddvd_r = 1;
+ break;
+ case 0x52:
+ info(udev, "profile 0x%02x media_hddvd_rw\n", cur_profile);
+ cd_media = 1;
+ cd_media_hddvd_rw = 1;
+ break;
+ default:
+ info(udev, "profile 0x%02x <ignored>\n", cur_profile);
+ break;
+ }
+}
+
static int feature_profiles(struct udev *udev, const unsigned char *profiles, size_t size)
{
unsigned int i;
return 0;
}
+/* returns 0 if media was detected */
static int cd_profiles_old_mmc(struct udev *udev, int fd)
{
struct scsi_cmd sc;
return 0;
}
+/* returns 0 if media was detected */
static int cd_profiles(struct udev *udev, int fd)
{
struct scsi_cmd sc;
unsigned int len;
unsigned int i;
int err;
+ int ret;
+
+ ret = -1;
/* First query the current profile */
scsi_cmd_init(udev, &sc, features, sizeof(features));
if (SK(err) == 0x5 && ASC(err) == 0x20) {
info(udev, "drive is pre-MMC2 and does not support 46h get configuration command\n");
info(udev, "trying to work around the problem\n");
- return cd_profiles_old_mmc(udev, fd);
+ ret = cd_profiles_old_mmc(udev, fd);
}
- return -1;
+ goto out;
}
cur_profile = features[6] << 8 | features[7];
if (cur_profile > 0) {
info(udev, "current profile 0x%02x\n", cur_profile);
+ feature_profile_media (udev, cur_profile);
+ ret = 0; /* we have media */
} else {
info(udev, "no current profile, assuming no media\n");
- return -1;
}
- switch (cur_profile) {
- case 0x03:
- case 0x04:
- case 0x05:
- info(udev, "profile 0x%02x \n", cur_profile);
- cd_media = 1;
- cd_media_mo = 1;
- break;
- case 0x08:
- info(udev, "profile 0x%02x media_cd_rom\n", cur_profile);
- cd_media = 1;
- cd_media_cd_rom = 1;
- break;
- case 0x09:
- info(udev, "profile 0x%02x media_cd_r\n", cur_profile);
- cd_media = 1;
- cd_media_cd_r = 1;
- break;
- case 0x0a:
- info(udev, "profile 0x%02x media_cd_rw\n", cur_profile);
- cd_media = 1;
- cd_media_cd_rw = 1;
- break;
- case 0x10:
- info(udev, "profile 0x%02x media_dvd_ro\n", cur_profile);
- cd_media = 1;
- cd_media_dvd_rom = 1;
- break;
- case 0x11:
- info(udev, "profile 0x%02x media_dvd_r\n", cur_profile);
- cd_media = 1;
- cd_media_dvd_r = 1;
- break;
- case 0x12:
- info(udev, "profile 0x%02x media_dvd_ram\n", cur_profile);
- cd_media = 1;
- cd_media_dvd_ram = 1;
- break;
- case 0x13:
- info(udev, "profile 0x%02x media_dvd_rw_ro\n", cur_profile);
- cd_media = 1;
- cd_media_dvd_rw = 1;
- cd_media_dvd_rw_ro = 1;
- break;
- case 0x14:
- info(udev, "profile 0x%02x media_dvd_rw_seq\n", cur_profile);
- cd_media = 1;
- cd_media_dvd_rw = 1;
- cd_media_dvd_rw_seq = 1;
- break;
- case 0x1B:
- info(udev, "profile 0x%02x media_dvd_plus_r\n", cur_profile);
- cd_media = 1;
- cd_media_dvd_plus_r = 1;
- break;
- case 0x1A:
- info(udev, "profile 0x%02x media_dvd_plus_rw\n", cur_profile);
- cd_media = 1;
- cd_media_dvd_plus_rw = 1;
- break;
- case 0x2A:
- info(udev, "profile 0x%02x media_dvd_plus_rw_dl\n", cur_profile);
- cd_media = 1;
- cd_media_dvd_plus_rw_dl = 1;
- break;
- case 0x2B:
- info(udev, "profile 0x%02x media_dvd_plus_r_dl\n", cur_profile);
- cd_media = 1;
- cd_media_dvd_plus_r_dl = 1;
- break;
- case 0x40:
- info(udev, "profile 0x%02x media_bd\n", cur_profile);
- cd_media = 1;
- cd_media_bd = 1;
- break;
- case 0x41:
- case 0x42:
- info(udev, "profile 0x%02x media_bd_r\n", cur_profile);
- cd_media = 1;
- cd_media_bd_r = 1;
- break;
- case 0x43:
- info(udev, "profile 0x%02x media_bd_re\n", cur_profile);
- cd_media = 1;
- cd_media_bd_re = 1;
- break;
- case 0x50:
- info(udev, "profile 0x%02x media_hddvd\n", cur_profile);
- cd_media = 1;
- cd_media_hddvd = 1;
- break;
- case 0x51:
- info(udev, "profile 0x%02x media_hddvd_r\n", cur_profile);
- cd_media = 1;
- cd_media_hddvd_r = 1;
- break;
- case 0x52:
- info(udev, "profile 0x%02x media_hddvd_rw\n", cur_profile);
- cd_media = 1;
- cd_media_hddvd_rw = 1;
- break;
- default:
- info(udev, "profile 0x%02x <ignored>\n", cur_profile);
- break;
- }
-
-
len = features[0] << 24 | features[1] << 16 | features[2] << 8 | features[3];
info(udev, "GET CONFIGURATION: size of features buffer 0x%04x\n", len);
break;
}
}
-
- return 0;
+out:
+ return ret;
}
static int cd_media_info(struct udev *udev, int fd)
goto print;
/* read drive and possibly current profile */
- if (cd_profiles(udev, fd) < 0)
+ if (cd_profiles(udev, fd) != 0)
goto print;
+ /* at this point we are guaranteed to have media in the
+ * drive - find out more about it */
+
/* get session/track info */
cd_media_toc(udev, fd);