1 /***************************************************************************
2 * Copyright (C) 2007 by Arep *
3 * Support is provided through the forums at *
4 * http://wii.console-tribe.com *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20 ***************************************************************************/
22 #ifndef DVD_DRIVE_H_INCLUDED
23 #define DVD_DRIVE_H_INCLUDED
26 #include <sys/types.h>
29 typedef struct dvd_drive_s dvd_drive;
33 DVD_VOLUME_LOCK_OK = 0,
34 DVD_VOLUME_LOCK_UNAVAILABLE = 1,
35 DVD_VOLUME_LOCK_FAILED = -1
36 } dvd_volume_lock_result;
44 /* Snapshot of the most recently executed MMC command. This is retained even
45 * when the caller requested quiet error handling so release builds can report
46 * actionable seed/cache transport diagnostics without enabling DEBUG/VERBOSE. */
57 } dvd_command_diagnostic;
69 dvd_data_direction direction;
77 dvd_drive *dvd_drive_new (char *device, u_int32_t command);
78 void *dvd_drive_destroy (dvd_drive *d);
79 int dvd_read_sector_dummy (dvd_drive *dvd, u_int32_t sector, u_int32_t sectors, req_sense *sense, u_int8_t *extbuf, size_t extbufsize);
80 int dvd_read_sector_streaming (dvd_drive *dvd, u_int32_t sector, req_sense *sense, u_int8_t *extbuf, size_t extbufsize);
81 int dvd_read_streaming (dvd_drive *dvd, u_int32_t sector, u_int32_t sectors, req_sense *sense, u_int8_t *extbuf, size_t extbufsize);
82 int dvd_flush_cache_READ12 (dvd_drive *dvd, u_int32_t sector, req_sense *sense);
83 int dvd_start_stop_unit (dvd_drive *dvd, bool start, bool load_eject, req_sense *sense);
84 int dvd_set_door_lock (dvd_drive *dvd, bool locked);
85 int dvd_stop_unit (dvd_drive *dvd, bool start, req_sense *sense);
86 int dvd_media_cycle (dvd_drive *dvd, req_sense *sense);
87 int dvd_wait_ready (dvd_drive *dvd, unsigned int timeout_ms);
88 int dvd_test_unit_ready (dvd_drive *dvd, req_sense *sense);
89 int dvd_read_capacity_10 (dvd_drive *dvd, u_int32_t *sectors, u_int32_t *sector_size, req_sense *sense);
90 int dvd_read_10 (dvd_drive *dvd, u_int32_t sector, u_int32_t sectors, req_sense *sense, u_int8_t *extbuf, size_t extbufsize);
91 int dvd_mode_sense_10 (dvd_drive *dvd, u_int8_t page, u_int8_t *extbuf, size_t extbufsize, req_sense *sense);
92 int dvd_mode_select_10 (dvd_drive *dvd, const u_int8_t *buf, size_t bufsize, req_sense *sense);
93 int dvd_mode_select_6 (dvd_drive *dvd, const u_int8_t *buf, size_t bufsize, req_sense *sense);
94 int dvd_read_dvd_structure (dvd_drive *dvd, u_int8_t format, u_int8_t layer, u_int8_t *extbuf, size_t extbufsize, req_sense *sense);
95 int dvd_xbox_gdr8050l_unlock (dvd_drive *dvd, u_int32_t *unlocked_sectors);
96 int dvd_xbox_vendor_lock (dvd_drive *dvd);
97 int dvd_xbox_vendor_unlock_wxripper (dvd_drive *dvd, u_int32_t *unlocked_sectors);
98 int dvd_xbox_vendor_set_error_skip (dvd_drive *dvd, bool enabled);
99 int dvd_xbox_prepare_game_view (dvd_drive *dvd, u_int32_t *sectors, u_int32_t *sector_size);
100 int dvd_refresh_volume (dvd_drive *dvd);
101 int dvd_lock_volume (dvd_drive *dvd);
102 int dvd_xbox_refresh_volume (dvd_drive *dvd);
103 int dvd_xbox_lock_volume (dvd_drive *dvd);
104 bool dvd_is_xbox_drive (dvd_drive *dvd);
105 bool dvd_is_xbox_unlock_drive (dvd_drive *dvd);
106 bool dvd_is_xbox_challenge_drive (dvd_drive *dvd);
107 bool dvd_is_xbox_vendor_unlock_drive (dvd_drive *dvd);
108 int dvd_set_speed (dvd_drive *dvd, u_int32_t speed, req_sense *sense);
109 int dvd_get_size (dvd_drive *dvd, u_int32_t *size, req_sense *sense);
110 int dvd_get_layerbreak (dvd_drive *dvd, u_int32_t *layerbreak, req_sense *sense);
111 int dvd_set_streaming (dvd_drive *dvd, u_int32_t speed, req_sense *sense);
112 int dvd_memdump (dvd_drive *dvd, u_int32_t block_off, u_int32_t block_len, u_int32_t block_size, u_int8_t *buf);
113 char *dvd_get_vendor (dvd_drive *dvd);
114 char *dvd_get_product_id (dvd_drive *dvd);
115 char *dvd_get_product_revision (dvd_drive *dvd);
116 char *dvd_get_model_string (dvd_drive *dvd);
117 char *dvd_get_device (dvd_drive *dvd);
118 void *dvd_get_native_handle (dvd_drive *dvd);
119 bool dvd_get_support_status (dvd_drive *dvd);
120 u_int32_t dvd_get_def_method (dvd_drive *dvd);
121 u_int32_t dvd_get_command (dvd_drive *dvd);
122 const char *dvd_get_hlds_e7_profile_name (dvd_drive *dvd);
123 const char *dvd_get_hlds_e7_support_tier (dvd_drive *dvd);
124 const char *dvd_get_hlds_e7_family (dvd_drive *dvd);
125 const char *dvd_get_hlds_e7_tokens (dvd_drive *dvd);
126 const char *dvd_get_hlds_e7_record_id (dvd_drive *dvd);
127 const char *dvd_get_hlds_e7_notes (dvd_drive *dvd);
128 u_int32_t dvd_get_hlds_e7_type (dvd_drive *dvd);
129 u_int32_t dvd_get_hlds_e7_cache_base (dvd_drive *dvd);
130 u_int32_t dvd_get_hlds_e7_mem_blocks (dvd_drive *dvd);
131 u_int32_t dvd_get_hlds_e7_static_cdb_base (dvd_drive *dvd);
132 u_int32_t dvd_get_hlds_e7_static_gate (dvd_drive *dvd);
133 int dvd_get_hlds_e7_preferred_method (dvd_drive *dvd);
134 void dvd_set_hlds_e7_runtime_profile (dvd_drive *dvd, u_int32_t type, u_int32_t cache_base, u_int32_t mem_blocks);
136 /* The following are exported for use by drive-specific functions */
137 typedef int (*dvd_drive_memdump_func) (dvd_drive *dvd, u_int32_t block_off, u_int32_t block_len, u_int32_t block_size, u_int8_t *buf);
138 void dvd_init_command (mmc_command *mmc, u_int8_t *buf, int len, req_sense *sense);
139 int dvd_execute_cmd (dvd_drive *dvd, mmc_command *mmc, bool ignore_errors);
140 bool dvd_get_last_command_diagnostic (dvd_drive *dvd, dvd_command_diagnostic *out);