git subrepo clone https://github.com/libretro/libretro-common.git deps/libretro-common
[pcsx_rearmed.git] / deps / libretro-common / include / cdrom / cdrom.h
CommitLineData
3719602c
PC
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
38struct string_list;
39
40RETRO_BEGIN_DECLS
41
42typedef struct
43{
44 unsigned short g1_timeout;
45 unsigned short g2_timeout;
46 unsigned short g3_timeout;
47} cdrom_group_timeouts_t;
48
49typedef 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
63typedef 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
71void cdrom_lba_to_msf(unsigned lba, unsigned char *min, unsigned char *sec, unsigned char *frame);
72
73unsigned cdrom_msf_to_lba(unsigned char min, unsigned char sec, unsigned char frame);
74
75void increment_msf(unsigned char *min, unsigned char *sec, unsigned char *frame);
76
77int cdrom_read_subq(libretro_vfs_implementation_file *stream, unsigned char *buf, size_t len);
78
79int 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 */
82int cdrom_get_inquiry(libretro_vfs_implementation_file *stream, char *model, int len, bool *is_cdrom);
83
84int 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
86int cdrom_set_read_speed(libretro_vfs_implementation_file *stream, unsigned speed);
87
88int cdrom_stop(libretro_vfs_implementation_file *stream);
89
90int cdrom_unlock(libretro_vfs_implementation_file *stream);
91
92int cdrom_open_tray(libretro_vfs_implementation_file *stream);
93
94int cdrom_close_tray(libretro_vfs_implementation_file *stream);
95
96/* must be freed by the caller */
97struct string_list* cdrom_get_available_drives(void);
98
99bool cdrom_is_media_inserted(libretro_vfs_implementation_file *stream);
100
101bool cdrom_drive_has_media(const char drive);
102
103void cdrom_get_current_config_core(libretro_vfs_implementation_file *stream);
104
105void cdrom_get_current_config_profiles(libretro_vfs_implementation_file *stream);
106
107void cdrom_get_current_config_cdread(libretro_vfs_implementation_file *stream);
108
109void cdrom_get_current_config_multiread(libretro_vfs_implementation_file *stream);
110
111void cdrom_get_current_config_random_readable(libretro_vfs_implementation_file *stream);
112
113int cdrom_get_sense(libretro_vfs_implementation_file *stream, unsigned char *sense, size_t len);
114
115bool cdrom_set_read_cache(libretro_vfs_implementation_file *stream, bool enabled);
116
117bool cdrom_get_timeouts(libretro_vfs_implementation_file *stream, cdrom_group_timeouts_t *timeouts);
118
119bool cdrom_has_atip(libretro_vfs_implementation_file *stream);
120
121void cdrom_device_fillpath(char *path, size_t len, char drive, unsigned char track, bool is_cue);
122
123RETRO_END_DECLS
124
125#endif