Search
lxdream.org :: lxdream/src/gdrom/gdrom.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdrom.h
changeset 720:b5594d1ac80a
prev709:18c39a8e504c
next736:a02d1475ccfd
author nkeynes
date Sat Jul 05 11:57:36 2008 +0000 (14 years ago)
permissions -rw-r--r--
last change Get OS X cdrom driver to the 'sort of working' stage. Hide most of the IOKit
fun in a separate osx_iokit module.
file annotate diff log raw
nkeynes@125
     1
/**
nkeynes@561
     2
 * $Id$
nkeynes@125
     3
 *
nkeynes@678
     4
 * This file defines the public structures and functions exported by the 
nkeynes@678
     5
 * GD-Rom subsystem
nkeynes@125
     6
 *
nkeynes@125
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@125
     8
 *
nkeynes@125
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@125
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@125
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@125
    12
 * (at your option) any later version.
nkeynes@125
    13
 *
nkeynes@125
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@125
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@125
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@125
    17
 * GNU General Public License for more details.
nkeynes@125
    18
 */
nkeynes@125
    19
nkeynes@678
    20
#ifndef lxdream_gdrom_H
nkeynes@678
    21
#define lxdream_gdrom_H 1
nkeynes@125
    22
nkeynes@678
    23
#include "lxdream.h"
nkeynes@678
    24
#include "hook.h"
nkeynes@678
    25
#include <glib/glist.h>
nkeynes@342
    26
nkeynes@149
    27
typedef uint16_t gdrom_error_t;
nkeynes@149
    28
nkeynes@709
    29
nkeynes@709
    30
struct gdrom_device {
nkeynes@709
    31
    char *name;  // internal name
nkeynes@709
    32
    char *device_name; // Human-readable device name
nkeynes@709
    33
};
nkeynes@709
    34
nkeynes@709
    35
typedef struct gdrom_device *gdrom_device_t;
nkeynes@709
    36
nkeynes@678
    37
typedef struct gdrom_disc *gdrom_disc_t;
nkeynes@138
    38
nkeynes@678
    39
typedef gboolean (*gdrom_disc_change_hook_t)( gdrom_disc_t new_disc, const gchar *new_disc_name, void *user_data );
nkeynes@720
    40
DECLARE_HOOK(gdrom_disc_change_hook, gdrom_disc_change_hook_t);
nkeynes@138
    41
nkeynes@720
    42
typedef gboolean (*gdrom_drive_list_change_hook_t)( GList *drive_list, void *user_data );
nkeynes@720
    43
DECLARE_HOOK(gdrom_drive_list_change_hook, gdrom_drive_list_change_hook_t);
nkeynes@125
    44
nkeynes@138
    45
/**
nkeynes@138
    46
 * Open an image file
nkeynes@138
    47
 */
nkeynes@138
    48
gdrom_disc_t gdrom_image_open( const gchar *filename );
nkeynes@138
    49
nkeynes@138
    50
/**
nkeynes@422
    51
 * Dump image info
nkeynes@422
    52
 */
nkeynes@422
    53
void gdrom_image_dump_info( gdrom_disc_t d );
nkeynes@422
    54
nkeynes@245
    55
nkeynes@138
    56
/**
nkeynes@138
    57
 * Shortcut to open and mount an image file
nkeynes@433
    58
 * @return true on success
nkeynes@138
    59
 */
nkeynes@433
    60
gboolean gdrom_mount_image( const gchar *filename );
nkeynes@138
    61
nkeynes@138
    62
void gdrom_mount_disc( gdrom_disc_t disc );
nkeynes@138
    63
nkeynes@138
    64
void gdrom_unmount_disc( void );
nkeynes@138
    65
nkeynes@138
    66
gboolean gdrom_is_mounted( void );
nkeynes@138
    67
nkeynes@464
    68
gdrom_disc_t gdrom_get_current_disc();
nkeynes@464
    69
nkeynes@678
    70
const gchar *gdrom_get_current_disc_name();
nkeynes@678
    71
nkeynes@138
    72
uint32_t gdrom_read_sectors( uint32_t sector, uint32_t sector_count,
nkeynes@422
    73
			     int mode, unsigned char *buf, uint32_t *length );
nkeynes@125
    74
nkeynes@678
    75
nkeynes@613
    76
/**
nkeynes@678
    77
 * Retrieve the disc table of contents, and write it into the buffer in the 
nkeynes@678
    78
 * format expected by the DC.
nkeynes@678
    79
 * @return 0 on success, error code on failure (eg no disc mounted)
nkeynes@613
    80
 */
nkeynes@678
    81
gdrom_error_t gdrom_get_toc( unsigned char *buf );
nkeynes@678
    82
nkeynes@678
    83
/**
nkeynes@678
    84
 * Retrieve the short (6-byte) session info, and write it into the buffer.
nkeynes@678
    85
 * @return 0 on success, error code on failure.
nkeynes@678
    86
 */
nkeynes@678
    87
gdrom_error_t gdrom_get_info( unsigned char *buf, int session );
nkeynes@678
    88
nkeynes@678
    89
uint8_t gdrom_get_track_no_by_lba( uint32_t lba );
nkeynes@613
    90
nkeynes@709
    91
nkeynes@709
    92
/**
nkeynes@709
    93
 * Native CD-ROM API - provided by drivers/cd_*.c
nkeynes@709
    94
 *
nkeynes@709
    95
 * A device name is either a system special file (most unixes) or a url of the
nkeynes@709
    96
 * form dvd://<identifier> or cd://<identifier>, where <identifier> is a system
nkeynes@709
    97
 * defined string that uniquely identifies a particular device.
nkeynes@709
    98
 */
nkeynes@709
    99
nkeynes@709
   100
/**
nkeynes@709
   101
 * Return a list of gdrom_device_t defining all CD/DVD drives in the host system.
nkeynes@709
   102
 */
nkeynes@709
   103
GList *cdrom_get_native_devices();
nkeynes@709
   104
nkeynes@709
   105
/**
nkeynes@709
   106
 * Open a native device given a device name and url method. Eg, for the url dvd://1
nkeynes@709
   107
 * this function will be invoked with method = "dvd" and name = "1"
nkeynes@709
   108
 * 
nkeynes@709
   109
 * @return NULL on failure, otherwise a valid gdrom_disc_t that can be mounted.
nkeynes@709
   110
 */
nkeynes@709
   111
gdrom_disc_t cdrom_open_device( const gchar *method, const gchar *name );
nkeynes@709
   112
nkeynes@125
   113
#endif
.