1 #include "libretro-cdrom.h"
2 #include "../deps/libretro-common/cdrom/cdrom.c"
3 #if defined(__linux__) && !defined(ANDROID)
4 //#include <linux/cdrom.h>
7 static int cdrom_send_command_dummy(const libretro_vfs_implementation_file *stream,
8 CDROM_CMD_Direction dir, void *buf, size_t len, unsigned char *cmd, size_t cmd_len,
9 unsigned char *sense, size_t sense_len)
14 static int cdrom_send_command_once(const libretro_vfs_implementation_file *stream,
15 CDROM_CMD_Direction dir, void *buf, size_t len, unsigned char *cmd, size_t cmd_len)
17 unsigned char sense[CDROM_MAX_SENSE_BYTES] = {0};
19 #if defined(__linux__) && !defined(ANDROID)
20 cdrom_send_command_linux
21 #elif defined(_WIN32) && !defined(_XBOX)
22 cdrom_send_command_win32
24 cdrom_send_command_dummy
26 (stream, dir, buf, len, cmd, cmd_len, sense, sizeof(sense));
29 cdrom_print_sense_data(sense, sizeof(sense));
31 (void)cdrom_send_command_dummy;
35 // "extensions" to libretro-common
36 int cdrom_set_read_speed_x(libretro_vfs_implementation_file *stream, unsigned speed)
38 // SET CD-ROM SPEED, DA is newer?
39 unsigned char cmd1[] = {0xDA, 0, speed - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
40 unsigned char cmd2[] = {0xBB, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
42 ret = cdrom_send_command_once(stream, DIRECTION_NONE, NULL, 0, cmd1, sizeof(cmd1));
44 #if defined(__linux__) && !defined(ANDROID)
45 // doesn't work, too late?
46 //ret = ioctl(fileno(stream->fp), CDROM_SELECT_SPEED, &speed);
50 speed = speed * 2352 * 75 / 1024;
53 ret = cdrom_send_command_once(stream, DIRECTION_NONE, NULL, 0, cmd2, sizeof(cmd2));
58 int cdrom_read_sector(libretro_vfs_implementation_file *stream,
59 unsigned int lba, void *b)
61 unsigned char cmd[] = {0xBE, 0, 0, 0, 0, 0, 0, 0, 1, 0xF8, 0, 0};
66 return cdrom_send_command_once(stream, DIRECTION_IN, b, 2352, cmd, sizeof(cmd));
69 // vim:sw=3:ts=3:expandtab