1.1 --- a/src/gdrom/linux.c Sat Oct 06 09:03:24 2007 +0000
1.2 +++ b/src/gdrom/linux.c Sat Oct 27 05:44:54 2007 +0000
1.5 - * $Id: linux.c,v 1.5 2007-10-06 08:58:00 nkeynes Exp $
1.6 + * $Id: linux.c,v 1.6 2007-10-27 05:44:54 nkeynes Exp $
1.8 * Linux cd-rom device driver.
1.11 #include <linux/cdrom.h>
1.12 #include <sys/stat.h>
1.13 #include <sys/ioctl.h>
1.17 #include "gdrom/gdrom.h"
1.18 #include "gdrom/packet.h"
1.21 struct gdrom_image_class linux_device_class = { "Linux", NULL,
1.22 linux_image_is_valid, linux_open_device };
1.23 +GList *gdrom_get_native_devices(void)
1.25 + GList *list = NULL;
1.26 + struct fstab *ent;
1.29 + while( (ent = getfsent()) != NULL ) {
1.30 + if( (stat(ent->fs_spec, &st) != -1) &&
1.31 + S_ISBLK(st.st_mode) ) {
1.32 + /* Got a valid block device - is it a CDROM? */
1.33 + int fd = open(ent->fs_spec, O_RDONLY|O_NONBLOCK);
1.36 + int caps = ioctl(fd, CDROM_GET_CAPABILITY);
1.37 + if( caps != -1 ) {
1.38 + /* Appears to support CDROM functions */
1.39 + list = g_list_append( list, g_strdup(ent->fs_spec) );
1.47 static gboolean linux_image_is_valid( FILE *f )
1.53 - disc = gdrom_image_new(f);
1.54 + disc = gdrom_image_new(filename, f);
1.55 if( disc == NULL ) {
1.56 ERROR("Unable to allocate memory!");
1.58 @@ -186,6 +211,33 @@
1.62 +static gdrom_error_t linux_play_audio( gdrom_disc_t disc, uint32_t lba, uint32_t endlba )
1.64 + int fd = fileno( ((gdrom_image_t)disc)->file );
1.65 + uint32_t real_sector = lba - CD_MSF_OFFSET;
1.66 + uint32_t length = endlba - lba;
1.67 + uint32_t buflen = 0;
1.68 + char cmd[12] = { 0xA5, 0,0,0, 0,0,0,0, 0,0,0,0 };
1.69 + cmd[2] = (real_sector >> 24) & 0xFF;
1.70 + cmd[3] = (real_sector >> 16) & 0xFF;
1.71 + cmd[4] = (real_sector >> 8) & 0xFF;
1.72 + cmd[5] = real_sector & 0xFF;
1.73 + cmd[6] = (length >> 24) & 0xFF;
1.74 + cmd[7] = (length >> 16) & 0xFF;
1.75 + cmd[8] = (length >> 8) & 0xFF;
1.76 + cmd[9] = length & 0xFF;
1.78 + return linux_send_command( fd, cmd, NULL, &buflen, CGC_DATA_NONE );
1.81 +static gdrom_error_t linux_stop_audio( gdrom_disc_t disc )
1.83 + int fd = fileno( ((gdrom_image_t)disc)->file );
1.84 + uint32_t buflen = 0;
1.85 + char cmd[12] = {0x4E,0,0,0, 0,0,0,0, 0,0,0,0};
1.86 + return linux_send_command( fd, cmd, NULL, &buflen, CGC_DATA_NONE );
1.89 static gdrom_error_t linux_read_sector( gdrom_disc_t disc, uint32_t sector,
1.90 int mode, unsigned char *buf, uint32_t *length )