1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (cdrom.h).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef __LIBRETRO_SDK_CDROM_H
24 #define __LIBRETRO_SDK_CDROM_H
29 #include <sys/types.h>
33 #include <retro_common_api.h>
34 #include <retro_inline.h>
44 unsigned short g1_timeout;
45 unsigned short g2_timeout;
46 unsigned short g3_timeout;
47 } cdrom_group_timeouts_t;
51 unsigned lba_start; /* start of pregap */
52 unsigned lba; /* start of data */
53 unsigned track_size; /* in LBAs */
55 unsigned char track_num;
56 unsigned char min; /* start of data */
65 cdrom_track_t track[99]; /* unsigned alignment */
66 cdrom_group_timeouts_t timeouts; /* unsigned short alignment */
67 unsigned char num_tracks;
71 void cdrom_lba_to_msf(unsigned lba, unsigned char *min, unsigned char *sec, unsigned char *frame);
73 unsigned cdrom_msf_to_lba(unsigned char min, unsigned char sec, unsigned char frame);
75 void increment_msf(unsigned char *min, unsigned char *sec, unsigned char *frame);
77 int cdrom_read_subq(libretro_vfs_implementation_file *stream, unsigned char *buf, size_t len);
79 int cdrom_write_cue(libretro_vfs_implementation_file *stream, char **out_buf, size_t *out_len, char cdrom_drive, unsigned char *num_tracks, cdrom_toc_t *toc);
81 /* needs 32 bytes for full vendor, product and version */
82 int cdrom_get_inquiry(libretro_vfs_implementation_file *stream, char *model, int len, bool *is_cdrom);
84 int cdrom_read(libretro_vfs_implementation_file *stream, cdrom_group_timeouts_t *timeouts, unsigned char min, unsigned char sec, unsigned char frame, void *s, size_t len, size_t skip);
86 int cdrom_set_read_speed(libretro_vfs_implementation_file *stream, unsigned speed);
88 int cdrom_stop(libretro_vfs_implementation_file *stream);
90 int cdrom_unlock(libretro_vfs_implementation_file *stream);
92 int cdrom_open_tray(libretro_vfs_implementation_file *stream);
94 int cdrom_close_tray(libretro_vfs_implementation_file *stream);
96 /* must be freed by the caller */
97 struct string_list* cdrom_get_available_drives(void);
99 bool cdrom_is_media_inserted(libretro_vfs_implementation_file *stream);
101 bool cdrom_drive_has_media(const char drive);
103 void cdrom_get_current_config_core(libretro_vfs_implementation_file *stream);
105 void cdrom_get_current_config_profiles(libretro_vfs_implementation_file *stream);
107 void cdrom_get_current_config_cdread(libretro_vfs_implementation_file *stream);
109 void cdrom_get_current_config_multiread(libretro_vfs_implementation_file *stream);
111 void cdrom_get_current_config_random_readable(libretro_vfs_implementation_file *stream);
113 int cdrom_get_sense(libretro_vfs_implementation_file *stream, unsigned char *sense, size_t len);
115 bool cdrom_set_read_cache(libretro_vfs_implementation_file *stream, bool enabled);
117 bool cdrom_get_timeouts(libretro_vfs_implementation_file *stream, cdrom_group_timeouts_t *timeouts);
119 bool cdrom_has_atip(libretro_vfs_implementation_file *stream);
121 void cdrom_device_fillpath(char *path, size_t len, char drive, unsigned char track, bool is_cue);