git subrepo clone https://github.com/libretro/libretro-common.git deps/libretro-common
[pcsx_rearmed.git] / deps / libretro-common / include / cdrom / cdrom.h
1 /* Copyright  (C) 2010-2020 The RetroArch team
2  *
3  * ---------------------------------------------------------------------------------------
4  * The following license statement only applies to this file (cdrom.h).
5  * ---------------------------------------------------------------------------------------
6  *
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:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  *
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.
21  */
22
23 #ifndef __LIBRETRO_SDK_CDROM_H
24 #define __LIBRETRO_SDK_CDROM_H
25
26 #include <stdio.h>
27 #include <stdint.h>
28 #include <stddef.h>
29 #include <sys/types.h>
30
31 #include <vfs/vfs.h>
32 #include <libretro.h>
33 #include <retro_common_api.h>
34 #include <retro_inline.h>
35
36 #include <boolean.h>
37
38 struct string_list;
39
40 RETRO_BEGIN_DECLS
41
42 typedef struct
43 {
44    unsigned short g1_timeout;
45    unsigned short g2_timeout;
46    unsigned short g3_timeout;
47 } cdrom_group_timeouts_t;
48
49 typedef struct
50 {
51    unsigned lba_start; /* start of pregap */
52    unsigned lba; /* start of data */
53    unsigned track_size; /* in LBAs */
54    unsigned track_bytes;
55    unsigned char track_num;
56    unsigned char min; /* start of data */
57    unsigned char sec;
58    unsigned char frame;
59    unsigned char mode;
60    bool audio;
61 } cdrom_track_t;
62
63 typedef struct
64 {
65    cdrom_track_t track[99];         /* unsigned alignment */
66    cdrom_group_timeouts_t timeouts; /* unsigned short alignment */
67    unsigned char num_tracks;
68    char drive;
69 } cdrom_toc_t;
70
71 void cdrom_lba_to_msf(unsigned lba, unsigned char *min, unsigned char *sec, unsigned char *frame);
72
73 unsigned cdrom_msf_to_lba(unsigned char min, unsigned char sec, unsigned char frame);
74
75 void increment_msf(unsigned char *min, unsigned char *sec, unsigned char *frame);
76
77 int cdrom_read_subq(libretro_vfs_implementation_file *stream, unsigned char *buf, size_t len);
78
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);
80
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);
83
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);
85
86 int cdrom_set_read_speed(libretro_vfs_implementation_file *stream, unsigned speed);
87
88 int cdrom_stop(libretro_vfs_implementation_file *stream);
89
90 int cdrom_unlock(libretro_vfs_implementation_file *stream);
91
92 int cdrom_open_tray(libretro_vfs_implementation_file *stream);
93
94 int cdrom_close_tray(libretro_vfs_implementation_file *stream);
95
96 /* must be freed by the caller */
97 struct string_list* cdrom_get_available_drives(void);
98
99 bool cdrom_is_media_inserted(libretro_vfs_implementation_file *stream);
100
101 bool cdrom_drive_has_media(const char drive);
102
103 void cdrom_get_current_config_core(libretro_vfs_implementation_file *stream);
104
105 void cdrom_get_current_config_profiles(libretro_vfs_implementation_file *stream);
106
107 void cdrom_get_current_config_cdread(libretro_vfs_implementation_file *stream);
108
109 void cdrom_get_current_config_multiread(libretro_vfs_implementation_file *stream);
110
111 void cdrom_get_current_config_random_readable(libretro_vfs_implementation_file *stream);
112
113 int cdrom_get_sense(libretro_vfs_implementation_file *stream, unsigned char *sense, size_t len);
114
115 bool cdrom_set_read_cache(libretro_vfs_implementation_file *stream, bool enabled);
116
117 bool cdrom_get_timeouts(libretro_vfs_implementation_file *stream, cdrom_group_timeouts_t *timeouts);
118
119 bool cdrom_has_atip(libretro_vfs_implementation_file *stream);
120
121 void cdrom_device_fillpath(char *path, size_t len, char drive, unsigned char track, bool is_cue);
122
123 RETRO_END_DECLS
124
125 #endif