4 * This file defines the public structures and functions exported by the
7 * Copyright (c) 2005 Nathan Keynes.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 #ifndef lxdream_gdrom_H
21 #define lxdream_gdrom_H 1
25 #include <glib/glist.h>
31 #define GDROM_TOC_SIZE (102*4) /* Size of GDROM TOC structure */
32 #define GDROM_SESSION_INFO_SIZE 6 /* Size of GDROM session info structure */
33 #define GDROM_SHORT_STATUS_SIZE 14 /* Size of GDROM short status structure */
35 typedef uint16_t gdrom_error_t;
39 char *name; // internal name
40 char *device_name; // Human-readable device name
43 typedef struct gdrom_device *gdrom_device_t;
45 typedef struct gdrom_disc *gdrom_disc_t;
47 typedef gboolean (*gdrom_disc_change_hook_t)( gdrom_disc_t new_disc, const gchar *new_disc_name, void *user_data );
48 DECLARE_HOOK(gdrom_disc_change_hook, gdrom_disc_change_hook_t);
50 typedef gboolean (*gdrom_drive_list_change_hook_t)( GList *drive_list, void *user_data );
51 DECLARE_HOOK(gdrom_drive_list_change_hook, gdrom_drive_list_change_hook_t);
56 gdrom_disc_t gdrom_image_open( const gchar *filename );
59 * Read image bootstrap info
61 gboolean gdrom_image_read_info( gdrom_disc_t d );
65 * Shortcut to open and mount an image file
66 * @return true on success
68 gboolean gdrom_mount_image( const gchar *filename );
70 void gdrom_mount_disc( gdrom_disc_t disc );
72 void gdrom_unmount_disc( void );
74 gboolean gdrom_is_mounted( void );
76 gdrom_disc_t gdrom_get_current_disc();
78 const gchar *gdrom_get_current_disc_name();
80 const gchar *gdrom_get_current_disc_title();
84 * Find the track (numbered from 1) containing the sector specified by LBA.
85 * Note: this function does not check for media change.
86 * @return The track number, or -1 if no track contains the sector.
88 int gdrom_disc_get_track_by_lba( gdrom_disc_t disc, uint32_t lba );
91 * Check if the disc contains valid media.
92 * @return PKT_ERR_OK if disc is present, otherwise PKT_ERR_NODISC
94 gdrom_error_t gdrom_disc_check_media( gdrom_disc_t disc );
97 * Retrieve the disc table of contents, and write it into the buffer in the
98 * format expected by the DC.
99 * @param disc The disc to read
100 * @param buf Buffer to receive the TOC data, which must be at least
101 * GDROM_TOC_SIZE bytes long.
102 * @return 0 on success, error code on failure (eg no disc)
104 gdrom_error_t gdrom_disc_get_toc( gdrom_disc_t disc, unsigned char *buf );
107 * Retrieve the short (6-byte) session info, and write it into the buffer.
108 * @param disc The disc to read
109 * @param session The session to read (numbered from 1), or 0
110 * @param buf Buffer to receive the session data, which must be at least
111 * GDROM_SESSION_INFO_SIZE bytes long.
112 * @return 0 on success, error code on failure.
114 gdrom_error_t gdrom_disc_get_session_info( gdrom_disc_t disc, int session, unsigned char *buf );
117 * Generate the position data as returned from a STATUS(1) packet.
118 * @param disc The disc to read
119 * @param lba The current head position
120 * @param buf The buffer to receive the position data, which must be at least
121 * GDROM_SHORT_STATUS_SIZE bytes long.
122 * @return 0 on success, error code on failure.
124 gdrom_error_t gdrom_disc_get_short_status( gdrom_disc_t disc, uint32_t lba, unsigned char *buf );
127 * Return the 1-byte status code for the disc (combination of IDE_DISC_* flags)
129 int gdrom_disc_get_drive_status( gdrom_disc_t disc );
132 * Native CD-ROM API - provided by drivers/cd_*.c
134 * A device name is either a system special file (most unixes) or a url of the
135 * form dvd://<identifier> or cd://<identifier>, where <identifier> is a system
136 * defined string that uniquely identifies a particular device.
140 * Return a list of gdrom_device_t defining all CD/DVD drives in the host system.
142 GList *cdrom_get_native_devices();
145 * Open a native device given a device name and url method. Eg, for the url dvd://1
146 * this function will be invoked with method = "dvd" and name = "1"
148 * @return NULL on failure, otherwise a valid gdrom_disc_t that can be mounted.
150 gdrom_disc_t cdrom_open_device( const gchar *method, const gchar *name );
156 #endif /* !lxdream_gdrom_H */
.