nkeynes@720: /** nkeynes@729: * $Id$ nkeynes@720: * nkeynes@720: * General OS X IOKit support (primarily for cdrom support) nkeynes@720: * nkeynes@720: * Copyright (c) 2008 Nathan Keynes. nkeynes@720: * nkeynes@720: * This program is free software; you can redistribute it and/or modify nkeynes@720: * it under the terms of the GNU General Public License as published by nkeynes@720: * the Free Software Foundation; either version 2 of the License, or nkeynes@720: * (at your option) any later version. nkeynes@720: * nkeynes@720: * This program is distributed in the hope that it will be useful, nkeynes@720: * but WITHOUT ANY WARRANTY; without even the implied warranty of nkeynes@720: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nkeynes@720: * GNU General Public License for more details. nkeynes@720: */ nkeynes@720: nkeynes@720: #ifndef lxdream_osx_iokit_H nkeynes@720: #define lxdream_osx_iokit_H 1 nkeynes@720: nkeynes@720: #include nkeynes@720: #include nkeynes@720: #include nkeynes@720: #include nkeynes@720: #include "lxdream.h" nkeynes@720: #include "hook.h" nkeynes@720: nkeynes@720: /** nkeynes@720: * CD-ROM drive visitor. Returns FALSE to continue iterating, TRUE if the desired CD-ROM nkeynes@720: * has been found. In the latter case, the io_object is returned from find_cdrom_device nkeynes@720: * (and not freed) nkeynes@720: */ nkeynes@720: typedef gboolean (*find_drive_callback_t)( io_object_t object, char *vendor, char *product, nkeynes@720: char *iopath, void *user_data ); nkeynes@720: nkeynes@720: /** nkeynes@720: * Search for a CD or DVD drive (instance of IODVDServices or IOCompactDiscServices). nkeynes@720: * The callback will be called repeatedly until either it returns TRUE, or all drives nkeynes@720: * have been iterated over. nkeynes@720: * nkeynes@720: * @return an IO registry entry for the matched drive, or 0 if no drives matched. nkeynes@720: * nkeynes@720: * Note: Use of IOCompactDiscServices is somewhat tentative since I don't have a Mac nkeynes@720: * with a CD-Rom drive. nkeynes@720: */ nkeynes@720: io_object_t find_cdrom_drive( find_drive_callback_t callback, void *user_data ); nkeynes@720: nkeynes@720: typedef struct osx_cdrom_drive *osx_cdrom_drive_t; nkeynes@720: nkeynes@720: /** nkeynes@720: * Construct an osx_cdrom_drive_t on the given device specification. nkeynes@720: * @return a new osx_cdrom_drive_t, or NULL if the device name was invalid. nkeynes@720: */ nkeynes@720: nkeynes@720: osx_cdrom_drive_t osx_cdrom_open_drive( const char *devname ); nkeynes@720: nkeynes@720: typedef void (*media_changed_callback_t)( osx_cdrom_drive_t drive, gboolean disc_present, void *user_data ); nkeynes@720: nkeynes@720: /** nkeynes@720: * Set the media changed callback for the drive. (NULL == no callback) nkeynes@720: */ nkeynes@720: void osx_cdrom_set_media_changed_callback( osx_cdrom_drive_t drive, nkeynes@720: media_changed_callback_t callback, nkeynes@720: void *user_data ); nkeynes@720: nkeynes@720: /** nkeynes@720: * Return a file handle for the cdrom drive (actually for the media). nkeynes@720: * @return an open file handle, or -1 if there was no media present or nkeynes@720: * the media could not be opened. nkeynes@720: */ nkeynes@720: int osx_cdrom_get_media_handle( osx_cdrom_drive_t drive ); nkeynes@720: nkeynes@720: void osx_cdrom_release_media_handle( osx_cdrom_drive_t drive ); nkeynes@720: nkeynes@720: /** Close on osx_cdrom_drive_t and release all associated resources. nkeynes@720: */ nkeynes@720: void osx_cdrom_close_drive( osx_cdrom_drive_t drive ); nkeynes@720: nkeynes@720: #endif /* !lxdream_osx_iokit_H */