Search
lxdream.org :: lxdream/src/drivers/cdrom/cdrom.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/cdrom/cdrom.h
changeset 1097:d4807997e450
next1099:566cdeb157ec
author nkeynes
date Sun Jan 31 18:35:06 2010 +1000 (10 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@1097
     1
/**
nkeynes@1097
     2
 * $Id$
nkeynes@1097
     3
 *
nkeynes@1097
     4
 * Copyright (c) 2005-2009 Nathan Keynes.
nkeynes@1097
     5
 *
nkeynes@1097
     6
 * This program is free software; you can redistribute it and/or modify
nkeynes@1097
     7
 * it under the terms of the GNU General Public License as published by
nkeynes@1097
     8
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@1097
     9
 * (at your option) any later version.
nkeynes@1097
    10
 *
nkeynes@1097
    11
 * This program is distributed in the hope that it will be useful,
nkeynes@1097
    12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@1097
    13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@1097
    14
 * GNU General Public License for more details.
nkeynes@1097
    15
 */
nkeynes@1097
    16
nkeynes@1097
    17
#ifndef cdrom_cdrom_H
nkeynes@1097
    18
#define cdrom_cdrom_H 1
nkeynes@1097
    19
nkeynes@1097
    20
#include <stdio.h>
nkeynes@1097
    21
#include <glib/glist.h>
nkeynes@1097
    22
#include "drivers/cdrom/defs.h"
nkeynes@1097
    23
#include "drivers/cdrom/sector.h"
nkeynes@1097
    24
nkeynes@1097
    25
#ifdef __cplusplus
nkeynes@1097
    26
extern "C" {
nkeynes@1097
    27
#endif
nkeynes@1097
    28
nkeynes@1097
    29
typedef enum {
nkeynes@1097
    30
    CDROM_DISC_NONE =  0x06,
nkeynes@1097
    31
    CDROM_DISC_AUDIO = 0x00,
nkeynes@1097
    32
    CDROM_DISC_NONXA = 0x10,
nkeynes@1097
    33
    CDROM_DISC_XA    = 0x20,
nkeynes@1097
    34
    CDROM_DISC_GDROM = 0x80
nkeynes@1097
    35
} cdrom_disc_type_t;
nkeynes@1097
    36
nkeynes@1097
    37
#define TRACK_FLAG_PREEMPH   0x10 /* Pre-emphasis (audio only) */
nkeynes@1097
    38
#define TRACK_FLAG_COPYPERM  0x20 /* Copy permitted */
nkeynes@1097
    39
#define TRACK_FLAG_DATA      0x40 /* Data track */
nkeynes@1097
    40
#define TRACK_FLAG_FOURCHAN  0x80 /* 4-channel audio */
nkeynes@1097
    41
nkeynes@1097
    42
struct cdrom_track {
nkeynes@1097
    43
    cdrom_trackno_t trackno;
nkeynes@1097
    44
    cdrom_sessionno_t sessionno;  /* session # containing this track */
nkeynes@1097
    45
    cdrom_lba_t lba;            /* start sector address */
nkeynes@1097
    46
    uint8_t flags;              /* Track flags */
nkeynes@1097
    47
    sector_source_t source;
nkeynes@1097
    48
};
nkeynes@1097
    49
nkeynes@1097
    50
/**
nkeynes@1097
    51
 * A CDROM disc, either an image file, or an open physical host device.
nkeynes@1097
    52
 */
nkeynes@1097
    53
struct cdrom_disc {
nkeynes@1097
    54
    struct sector_source source;
nkeynes@1097
    55
    const char *name; /* Filename or identifier used to open the disc */
nkeynes@1097
    56
    cdrom_disc_type_t disc_type;
nkeynes@1097
    57
    gchar mcn[14]; /* Media catalogue number, null terminated. */
nkeynes@1097
    58
    cdrom_trackno_t track_count;
nkeynes@1097
    59
    cdrom_sessionno_t session_count;
nkeynes@1097
    60
    cdrom_lba_t leadout; /* LBA of the disc leadout */
nkeynes@1097
    61
    struct cdrom_track track[99];
nkeynes@1097
    62
nkeynes@1097
    63
    /* Reference to an underlying source, if any. */
nkeynes@1097
    64
    sector_source_t base_source;
nkeynes@1097
    65
nkeynes@1097
    66
    /* Private implementation-specific data */
nkeynes@1097
    67
    void *impl_data;
nkeynes@1097
    68
nkeynes@1097
    69
    /** Check for media change. If the media cannot change (ie image file)
nkeynes@1097
    70
     * or is notified asynchonously, this should be a no-op. In the event of
nkeynes@1097
    71
     * a change, this function should update the structure according to the
nkeynes@1097
    72
     * new media (including TOC), and return TRUE.
nkeynes@1097
    73
     * @return TRUE if the media has changed since the last check, otherwise
nkeynes@1097
    74
     * FALSE.
nkeynes@1097
    75
     */
nkeynes@1097
    76
    gboolean (*check_media)(cdrom_disc_t disc);
nkeynes@1097
    77
nkeynes@1097
    78
    /**
nkeynes@1097
    79
     * Read the table of contents from the given file
nkeynes@1097
    80
     */
nkeynes@1097
    81
    gboolean (*read_toc)(cdrom_disc_t disc, ERROR *err);
nkeynes@1097
    82
nkeynes@1097
    83
    /**
nkeynes@1097
    84
     * Begin playing audio from the given lba address on the disc.
nkeynes@1097
    85
     */
nkeynes@1097
    86
    cdrom_error_t (*play_audio)(cdrom_disc_t disc, cdrom_lba_t lba, cdrom_count_t length);
nkeynes@1097
    87
nkeynes@1097
    88
    cdrom_error_t (*scan_audio)(cdrom_disc_t disc, cdrom_lba_t lba, gboolean direction);
nkeynes@1097
    89
nkeynes@1097
    90
    cdrom_error_t (*stop_audio)(cdrom_disc_t disc);
nkeynes@1097
    91
nkeynes@1097
    92
};
nkeynes@1097
    93
nkeynes@1097
    94
/**
nkeynes@1097
    95
 * Open an image file or device
nkeynes@1097
    96
 */
nkeynes@1097
    97
cdrom_disc_t cdrom_disc_open( const char *filename, ERROR *err );
nkeynes@1097
    98
nkeynes@1097
    99
/**
nkeynes@1097
   100
 * Get the track information for the given track. If there is no such track,
nkeynes@1097
   101
 * return NULL;
nkeynes@1097
   102
 */
nkeynes@1097
   103
cdrom_track_t cdrom_disc_get_track( cdrom_disc_t disc, cdrom_trackno_t track );
nkeynes@1097
   104
nkeynes@1097
   105
/**
nkeynes@1097
   106
 * Get the track information for the first track of the given session. If there
nkeynes@1097
   107
 * is no such session, return NULL;
nkeynes@1097
   108
 */
nkeynes@1097
   109
cdrom_track_t cdrom_disc_get_session( cdrom_disc_t disc, cdrom_sessionno_t session );
nkeynes@1097
   110
nkeynes@1097
   111
cdrom_track_t cdrom_disc_get_last_track( cdrom_disc_t disc );
nkeynes@1097
   112
nkeynes@1097
   113
cdrom_track_t cdrom_disc_prev_track( cdrom_disc_t disc, cdrom_track_t track );
nkeynes@1097
   114
cdrom_track_t cdrom_disc_next_track( cdrom_disc_t disc, cdrom_track_t track );
nkeynes@1097
   115
nkeynes@1097
   116
/**
nkeynes@1097
   117
 * Return the size of the track in sectors, including inter-track gap
nkeynes@1097
   118
 */
nkeynes@1097
   119
cdrom_count_t cdrom_disc_get_track_size( cdrom_disc_t disc, cdrom_track_t track );
nkeynes@1097
   120
nkeynes@1097
   121
/**
nkeynes@1097
   122
 * Find the track containing the sector specified by LBA.
nkeynes@1097
   123
 * Note: this function does not check for media change.
nkeynes@1097
   124
 * @return The track, or NULL if no track contains the sector.
nkeynes@1097
   125
 */
nkeynes@1097
   126
cdrom_track_t cdrom_disc_get_track_by_lba( cdrom_disc_t disc, cdrom_lba_t lba );
nkeynes@1097
   127
nkeynes@1097
   128
/** 
nkeynes@1097
   129
 * Check if the disc contains valid media.
nkeynes@1097
   130
 * @return CDROM_ERROR_OK if disc is present, otherwise CDROM_ERROR_NODISC
nkeynes@1097
   131
 */
nkeynes@1097
   132
cdrom_error_t cdrom_disc_check_media( cdrom_disc_t disc );
nkeynes@1097
   133
nkeynes@1097
   134
/**
nkeynes@1097
   135
 * Read sectors from the disc.
nkeynes@1097
   136
 * @return status code
nkeynes@1097
   137
 */
nkeynes@1097
   138
cdrom_error_t cdrom_disc_read_sectors( cdrom_disc_t disc, cdrom_lba_t lba, cdrom_count_t count, cdrom_read_mode_t mode,
nkeynes@1097
   139
                                       unsigned char *buf, size_t *length );
nkeynes@1097
   140
nkeynes@1097
   141
/**
nkeynes@1097
   142
 * Print the disc's table of contents to the given output stream.
nkeynes@1097
   143
 */
nkeynes@1097
   144
void cdrom_disc_print_toc( FILE *f, cdrom_disc_t disc );
nkeynes@1097
   145
nkeynes@1097
   146
#define cdrom_disc_ref(disc) sector_source_ref((sector_source_t)disc)
nkeynes@1097
   147
#define cdrom_disc_unref(disc) sector_source_unref((sector_source_t)disc)
nkeynes@1097
   148
nkeynes@1097
   149
#ifdef __cplusplus
nkeynes@1097
   150
}
nkeynes@1097
   151
#endif
nkeynes@1097
   152
nkeynes@1097
   153
#endif /* !cdrom_cdrom_H */
.