hal/hald/linux2/probing linux_dvd_rw_utils.c, 1.5, 1.6 linux_dvd_rw_utils.h, 1.3, 1.4 probe-storage.c, 1.21, 1.22

Danny Kukawka dkukawka at kemper.freedesktop.org
Tue May 9 13:28:03 PDT 2006


Update of /cvs/hal/hal/hald/linux2/probing
In directory kemper:/tmp/cvs-serv27206/hald/linux2/probing

Modified Files:
	linux_dvd_rw_utils.c linux_dvd_rw_utils.h probe-storage.c 
Log Message:
2006-05-09  Danny Kukawka  <danny.kukawka at web.de>

        * doc/spec/hal-spec.xml.in: added property for DVD+RW DL to spec
        * hald/linux2/probing/linux_dvd_rw_utils.c,
          hald/linux2/probing/linux_dvd_rw_utils.h: (get_dvd_r_rw_profile):
        reworked detection of device capabilities to get correct DVD-RW info
        and added DVD+RW DL detection.
        * hald/linux2/probing/probe-storage.c: (main): fixed mapping of
        return value of get_dvd_r_rw_profile() related to changes
        * libhal-storage/libhal-storage.c:
        (libhal_drive_policy_compute_display_name),
        (libhal_drive_from_udi):
        * libhal-storage/libhal-storage.h: added property DVD+RW DL



Index: linux_dvd_rw_utils.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/linux_dvd_rw_utils.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- linux_dvd_rw_utils.c	21 Jan 2006 03:26:30 -0000	1.5
+++ linux_dvd_rw_utils.c	9 May 2006 20:28:00 -0000	1.6
@@ -182,8 +182,7 @@
 get_dvd_r_rw_profile (int fd)
 {
 	ScsiCommand *cmd;
-	int retval = -1;
-	int dvd_plusr_dl = -1;
+	int retval = 0;
 	unsigned char page[20];
 	unsigned char *list;
 	int i, len;
@@ -224,38 +223,39 @@
 
 	for (i = 12; i < list[11]; i += 4) {
 		int profile = (list[i] << 8 | list[i + 1]);
-		/* 0x1B: DVD+R  == 0
-		 * 0x1A: DVD+RW == 1 
-		 * 0x2B: DVD+R DL == 3 */
-		if (profile == 0x1B) {
-			if (retval == 1)
-				retval = 2;
-			else
-				retval = 0;
-		} else if (profile == 0x1A) {
-			if (retval == 0)
-				retval = 2;
-			else
-				retval = 1;
-		} else if (profile == 0x2B) {
-			/* DVD+R DL*/
-			dvd_plusr_dl = 1;
+		/* 0x13: DVD-RW Restricted Overwrite
+		 * 0x14: DVD-RW Sequential
+		 * 0x1B: DVD+R 
+		 * 0x1A: DVD+RW  
+		 * 0x2A: DVD+RW DL
+		 * 0x2B: DVD+R DL 
+		 */
+
+		switch (profile) {
+			case 0x13:
+			case 0x14:
+				retval |= DRIVE_CDROM_CAPS_DVDRW;
+				break;
+			case 0x1B:
+				retval |= DRIVE_CDROM_CAPS_DVDPLUSR;
+				break;
+			case 0x1A:
+				retval |= DRIVE_CDROM_CAPS_DVDPLUSRW;
+				break;
+			case 0x2A:
+				retval |= DRIVE_CDROM_CAPS_DVDPLUSRWDL;
+				break;
+			case 0x2B:
+				retval |= DRIVE_CDROM_CAPS_DVDPLUSRDL;
+				break;
+			default:
+				break;
 		}
 	}
 
 	scsi_command_free (cmd);
 	free (list);
 	
-	/* to do: 
-	 * - check if DVD+R DL always implied also DVD+R and DVD+RW. 
-	 *   If so, we don't need this code. */
-	if (dvd_plusr_dl == 1) {
-		if(retval == 2 || retval == 1 ) 	
-			retval = 4;
-		else 
-			retval = 3; 
-	} 
-	
 	return retval;
 	
 }

Index: linux_dvd_rw_utils.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/linux_dvd_rw_utils.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- linux_dvd_rw_utils.h	21 Jan 2006 03:26:30 -0000	1.3
+++ linux_dvd_rw_utils.h	9 May 2006 20:28:00 -0000	1.4
@@ -11,6 +11,12 @@
 
 #include <glib.h>
 
+#define DRIVE_CDROM_CAPS_DVDRW        1
+#define DRIVE_CDROM_CAPS_DVDPLUSR     2
+#define DRIVE_CDROM_CAPS_DVDPLUSRW    4
+#define DRIVE_CDROM_CAPS_DVDPLUSRWDL  8
+#define DRIVE_CDROM_CAPS_DVDPLUSRDL  16
+
 int get_dvd_r_rw_profile (int fd);
 int get_read_write_speed (int fd, int *read_speed, int *write_speed, char **write_speeds);
 int get_disc_capacity_for_type (int fd, int type, guint64 *capacity);

Index: probe-storage.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/probing/probe-storage.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- probe-storage.c	22 Feb 2006 21:27:52 -0000	1.21
+++ probe-storage.c	9 May 2006 20:28:00 -0000	1.22
@@ -194,6 +194,7 @@
 			libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdram", FALSE, &error);
 			libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusr", FALSE, &error);
 			libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusrw", FALSE, &error);
+			libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusrwdl", FALSE, &error);
 			libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusrdl", FALSE, &error);
 			libhal_device_set_property_bool (ctx, udi, "storage.cdrom.bd", FALSE, &error);
 			libhal_device_set_property_bool (ctx, udi, "storage.cdrom.bdr", FALSE, &error);
@@ -212,28 +213,21 @@
 			if (capabilities & CDC_DVD) {
 				int profile;
 				
-				/** @todo FIXME BUG XXX: need to check for dvdrw, Blue-ray and HD DVD
-				 * (prolly need to rewrite much of the linux_dvdrw_utils.c file)
-				 */
-				
 				libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvd", TRUE, &error);
-				
+
 				profile = get_dvd_r_rw_profile (fd);
-				if (profile == 2) {
-					libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusr", TRUE, &error);
-					libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusrw", TRUE, &error);
-				} else if (profile == 0) {
+				dbg ("get_dvd_r_rw_profile returned: %d", profile);
+
+				if (profile & DRIVE_CDROM_CAPS_DVDRW)
+					libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdrw", TRUE, &error);
+				if (profile & DRIVE_CDROM_CAPS_DVDPLUSR)
 					libhal_device_set_property_bool(ctx, udi, "storage.cdrom.dvdplusr", TRUE, &error);
-				} else if (profile == 1) {
+				if (profile & DRIVE_CDROM_CAPS_DVDPLUSRW)
 					libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusrw", TRUE, &error);
-				} else if (profile == 3) {
-					libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusr", TRUE, &error);
-					libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusrdl", TRUE, &error);
-				} else if (profile == 4) {
-					libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusr", TRUE, &error);
-                                	libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusrw", TRUE, &error);
-				        libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusrdl", TRUE, &error);
-				}
+				if (profile & DRIVE_CDROM_CAPS_DVDPLUSRWDL)
+					libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusrwdl", TRUE, &error);
+				if (profile & DRIVE_CDROM_CAPS_DVDPLUSRDL)
+                                        libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdplusrdl", TRUE, &error);
 			}
 			if (capabilities & CDC_DVD_R) {
 				libhal_device_set_property_bool (ctx, udi, "storage.cdrom.dvdr", TRUE, &error);




More information about the hal-commit mailing list