Search
lxdream.org :: lxdream/src/gdrom/gdrom.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdrom.h
changeset 1097:d4807997e450
prev1023:264e2fd90be8
next1101:78e762cec843
author nkeynes
date Sun Jan 31 18:35:06 2010 +1000 (12 years ago)
permissions -rw-r--r--
last change Refactor CDROM host support
- Completely separate GDROM hardware (in gdrom/gdrom.c) from generic CDROM
support (now in drivers/cdrom)
- Add concept of 'sector sources' that can be mixed and matched to create
cdrom discs (makes support of arbitrary disc types much simpler)
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@1097
    25
#include "drivers/cdrom/defs.h"
nkeynes@678
    26
#include <glib/glist.h>
nkeynes@342
    27
nkeynes@736
    28
#ifdef __cplusplus
nkeynes@736
    29
extern "C" {
nkeynes@736
    30
#endif
nkeynes@736
    31
nkeynes@1023
    32
#define GDROM_TOC_SIZE (102*4) /* Size of GDROM TOC structure */
nkeynes@1023
    33
#define GDROM_SESSION_INFO_SIZE 6 /* Size of GDROM session info structure */
nkeynes@1023
    34
#define GDROM_SHORT_STATUS_SIZE 14 /* Size of GDROM short status structure */
nkeynes@1023
    35
nkeynes@1097
    36
typedef gboolean (*gdrom_disc_change_hook_t)( cdrom_disc_t new_disc, const gchar *new_disc_name, void *user_data );
nkeynes@720
    37
DECLARE_HOOK(gdrom_disc_change_hook, gdrom_disc_change_hook_t);
nkeynes@138
    38
nkeynes@720
    39
typedef gboolean (*gdrom_drive_list_change_hook_t)( GList *drive_list, void *user_data );
nkeynes@720
    40
DECLARE_HOOK(gdrom_drive_list_change_hook, gdrom_drive_list_change_hook_t);
nkeynes@125
    41
nkeynes@138
    42
/**
nkeynes@138
    43
 * Open an image file
nkeynes@138
    44
 */
nkeynes@1097
    45
cdrom_disc_t gdrom_image_open( const gchar *filename );
nkeynes@245
    46
nkeynes@138
    47
/**
nkeynes@138
    48
 * Shortcut to open and mount an image file
nkeynes@433
    49
 * @return true on success
nkeynes@138
    50
 */
nkeynes@433
    51
gboolean gdrom_mount_image( const gchar *filename );
nkeynes@138
    52
nkeynes@1097
    53
void gdrom_mount_disc( cdrom_disc_t disc );
nkeynes@138
    54
nkeynes@138
    55
void gdrom_unmount_disc( void );
nkeynes@138
    56
nkeynes@138
    57
gboolean gdrom_is_mounted( void );
nkeynes@138
    58
nkeynes@1097
    59
cdrom_disc_t gdrom_get_current_disc();
nkeynes@464
    60
nkeynes@678
    61
const gchar *gdrom_get_current_disc_name();
nkeynes@678
    62
nkeynes@837
    63
const gchar *gdrom_get_current_disc_title();
nkeynes@837
    64
nkeynes@1023
    65
/**
nkeynes@1097
    66
 * Find the track which should be checked for the
nkeynes@1097
    67
 * dreamcast bootstrap - this is the first data track on the last
nkeynes@1097
    68
 * session (where there are at least 2 sessions). If a boot track
nkeynes@1097
    69
 * cannot be found, returns NULL.
nkeynes@1023
    70
 */
nkeynes@1097
    71
cdrom_track_t gdrom_disc_get_boot_track( cdrom_disc_t disc );
nkeynes@1023
    72
nkeynes@1023
    73
/** 
nkeynes@1023
    74
 * Check if the disc contains valid media.
nkeynes@1097
    75
 * @return CDROM_ERROR_OK if disc is present, otherwise CDROM_ERROR_NODISC
nkeynes@1023
    76
 */
nkeynes@1097
    77
cdrom_error_t gdrom_check_media( );
nkeynes@678
    78
nkeynes@613
    79
/**
nkeynes@678
    80
 * Retrieve the disc table of contents, and write it into the buffer in the 
nkeynes@678
    81
 * format expected by the DC.
nkeynes@1023
    82
 * @param buf Buffer to receive the TOC data, which must be at least
nkeynes@1023
    83
 * GDROM_TOC_SIZE bytes long.
nkeynes@1023
    84
 * @return 0 on success, error code on failure (eg no disc)
nkeynes@613
    85
 */
nkeynes@1097
    86
cdrom_error_t gdrom_read_toc( unsigned char *buf );
nkeynes@678
    87
nkeynes@678
    88
/**
nkeynes@678
    89
 * Retrieve the short (6-byte) session info, and write it into the buffer.
nkeynes@1023
    90
 * @param session The session to read (numbered from 1), or 0 
nkeynes@1023
    91
 * @param buf Buffer to receive the session data, which must be at least
nkeynes@1023
    92
 * GDROM_SESSION_INFO_SIZE bytes long.
nkeynes@678
    93
 * @return 0 on success, error code on failure.
nkeynes@678
    94
 */
nkeynes@1097
    95
cdrom_error_t gdrom_read_session( int session, unsigned char *buf );
nkeynes@1023
    96
nkeynes@1023
    97
/**
nkeynes@1023
    98
 * Generate the position data as returned from a STATUS(1) packet. 
nkeynes@1023
    99
 * @param disc The disc to read
nkeynes@1023
   100
 * @param lba The current head position
nkeynes@1023
   101
 * @param buf The buffer to receive the position data, which must be at least
nkeynes@1023
   102
 * GDROM_SHORT_STATUS_SIZE bytes long.
nkeynes@1023
   103
 * @return 0 on success, error code on failure.
nkeynes@1023
   104
 */
nkeynes@1097
   105
cdrom_error_t gdrom_read_short_status( uint32_t lba, unsigned char *buf );
nkeynes@1097
   106
nkeynes@1097
   107
/**
nkeynes@1097
   108
 * Read sectors from the current disc.
nkeynes@1097
   109
 * @param lba Address of first sector to read
nkeynes@1097
   110
 * @param count Number of sectors to read
nkeynes@1097
   111
 * @param read_mode GDROM format read-mode
nkeynes@1097
   112
 * @param buf Buffer to receive read sectors
nkeynes@1097
   113
 * @param length If not null, will be written with the number of bytes read.
nkeynes@1097
   114
 * @return 0 on success, otherwise error code.
nkeynes@1097
   115
 */
nkeynes@1097
   116
cdrom_error_t gdrom_read_cd( cdrom_lba_t lba, cdrom_count_t count,
nkeynes@1097
   117
                             unsigned read_mode, unsigned char *buf, size_t *length );
nkeynes@1097
   118
nkeynes@1097
   119
cdrom_error_t gdrom_play_audio( cdrom_lba_t lba, cdrom_count_t count );
nkeynes@1023
   120
nkeynes@1023
   121
/**
nkeynes@1023
   122
 * Return the 1-byte status code for the disc (combination of IDE_DISC_* flags)
nkeynes@1023
   123
 */
nkeynes@1097
   124
int gdrom_get_drive_status( );
nkeynes@678
   125
nkeynes@709
   126
/**
nkeynes@1097
   127
 * Run GDROM time slice (if any)
nkeynes@709
   128
 */
nkeynes@1097
   129
void gdrom_run_slice( uint32_t nanosecs );
nkeynes@709
   130
nkeynes@736
   131
#ifdef __cplusplus
nkeynes@736
   132
}
nkeynes@125
   133
#endif
nkeynes@736
   134
nkeynes@736
   135
#endif /* !lxdream_gdrom_H */
.