1 /* 2 * Auich BeOS Driver for Intel Southbridge audio 3 * 4 * Copyright (c) 2003, Jerome Duval (jerome.duval@free.fr) 5 * 6 * Original code : BeOS Driver for Intel ICH AC'97 Link interface 7 * Copyright (c) 2002, Marcus Overhagen <marcus@overhagen.de> 8 * 9 * All rights reserved. 10 * Redistribution and use in source and binary forms, with or without modification, 11 * are permitted provided that the following conditions are met: 12 * 13 * - Redistributions of source code must retain the above copyright notice, 14 * this list of conditions and the following disclaimer. 15 * - Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 */ 31 32 #include <driver_settings.h> 33 #include <OS.h> 34 #include <MediaDefs.h> 35 #include <string.h> 36 #include <strings.h> 37 38 #include <kernel.h> 39 40 #include "hmulti_audio.h" 41 #include "multi.h" 42 #include "ac97.h" 43 44 //#define DEBUG 1 45 46 #include "debug.h" 47 #include "auich.h" 48 #include "util.h" 49 #include "io.h" 50 51 52 static void 53 auich_ac97_get_mix(void *card, const void *cookie, int32 type, float *values) { 54 auich_dev *dev = (auich_dev*)card; 55 ac97_source_info *info = (ac97_source_info *)cookie; 56 uint16 value, mask; 57 float gain; 58 59 switch(type) { 60 case B_MIX_GAIN: 61 value = auich_codec_read(&dev->config, info->reg); 62 //PRINT(("B_MIX_GAIN value : %u\n", value)); 63 if (info->type & B_MIX_STEREO) { 64 mask = ((1 << (info->bits + 1)) - 1) << 8; 65 gain = ((value & mask) >> 8) * info->granularity; 66 if (info->polarity == 1) 67 values[0] = info->max_gain - gain; 68 else 69 values[0] = gain - info->min_gain; 70 71 mask = ((1 << (info->bits + 1)) - 1); 72 gain = (value & mask) * info->granularity; 73 if (info->polarity == 1) 74 values[1] = info->max_gain - gain; 75 else 76 values[1] = gain - info->min_gain; 77 } else { 78 mask = ((1 << (info->bits + 1)) - 1); 79 gain = (value & mask) * info->granularity; 80 if (info->polarity == 1) 81 values[0] = info->max_gain - gain; 82 else 83 values[0] = gain - info->min_gain; 84 } 85 break; 86 case B_MIX_MUTE: 87 mask = ((1 << 1) - 1) << 15; 88 value = auich_codec_read(&dev->config, info->reg); 89 //PRINT(("B_MIX_MUTE value : %u\n", value)); 90 value &= mask; 91 values[0] = ((value >> 15) == 1) ? 1.0 : 0.0; 92 break; 93 case B_MIX_MICBOOST: 94 mask = ((1 << 1) - 1) << 6; 95 value = auich_codec_read(&dev->config, info->reg); 96 //PRINT(("B_MIX_MICBOOST value : %u\n", value)); 97 value &= mask; 98 values[0] = ((value >> 6) == 1) ? 1.0 : 0.0; 99 break; 100 case B_MIX_MUX: 101 mask = ((1 << 3) - 1); 102 value = auich_codec_read(&dev->config, AC97_RECORD_SELECT); 103 value &= mask; 104 //PRINT(("B_MIX_MUX value : %u\n", value)); 105 values[0] = (float)value; 106 break; 107 } 108 } 109 110 111 static void 112 auich_ac97_set_mix(void *card, const void *cookie, int32 type, float *values) { 113 auich_dev *dev = (auich_dev*)card; 114 ac97_source_info *info = (ac97_source_info *)cookie; 115 uint16 value, mask; 116 float gain; 117 118 switch(type) { 119 case B_MIX_GAIN: 120 value = auich_codec_read(&dev->config, info->reg); 121 if (info->type & B_MIX_STEREO) { 122 mask = ((1 << (info->bits + 1)) - 1) << 8; 123 value &= ~mask; 124 125 if (info->polarity == 1) 126 gain = info->max_gain - values[0]; 127 else 128 gain = values[0] - info->min_gain; 129 value |= ((uint16)(gain / info->granularity) << 8) & mask; 130 131 mask = ((1 << (info->bits + 1)) - 1); 132 value &= ~mask; 133 if (info->polarity == 1) 134 gain = info->max_gain - values[1]; 135 else 136 gain = values[1] - info->min_gain; 137 value |= ((uint16)(gain / info->granularity)) & mask; 138 } else { 139 mask = ((1 << (info->bits + 1)) - 1); 140 value &= ~mask; 141 if (info->polarity == 1) 142 gain = info->max_gain - values[0]; 143 else 144 gain = values[0] - info->min_gain; 145 value |= ((uint16)(gain / info->granularity)) & mask; 146 } 147 //PRINT(("B_MIX_GAIN value : %u\n", value)); 148 auich_codec_write(&dev->config, info->reg, value); 149 break; 150 case B_MIX_MUTE: 151 mask = ((1 << 1) - 1) << 15; 152 value = auich_codec_read(&dev->config, info->reg); 153 value &= ~mask; 154 value |= ((values[0] == 1.0 ? 1 : 0 ) << 15 & mask); 155 if (info->reg == AC97_SURR_VOLUME) { 156 // there is a independent mute for each channel 157 mask = ((1 << 1) - 1) << 7; 158 value &= ~mask; 159 value |= ((values[0] == 1.0 ? 1 : 0 ) << 7 & mask); 160 } 161 //PRINT(("B_MIX_MUTE value : %u\n", value)); 162 auich_codec_write(&dev->config, info->reg, value); 163 break; 164 case B_MIX_MICBOOST: 165 mask = ((1 << 1) - 1) << 6; 166 value = auich_codec_read(&dev->config, info->reg); 167 value &= ~mask; 168 value |= ((values[0] == 1.0 ? 1 : 0 ) << 6 & mask); 169 //PRINT(("B_MIX_MICBOOST value : %u\n", value)); 170 auich_codec_write(&dev->config, info->reg, value); 171 break; 172 case B_MIX_MUX: 173 mask = ((1 << 3) - 1); 174 value = ((int32)values[0]) & mask; 175 value = value | (value << 8); 176 //PRINT(("B_MIX_MUX value : %u\n", value)); 177 auich_codec_write(&dev->config, AC97_RECORD_SELECT, value); 178 break; 179 } 180 181 } 182 183 184 static int32 185 auich_create_group_control(multi_dev *multi, int32 *index, int32 parent, 186 int32 string, const char* name) { 187 int32 i = *index; 188 (*index)++; 189 multi->controls[i].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + i; 190 multi->controls[i].mix_control.parent = parent; 191 multi->controls[i].mix_control.flags = B_MULTI_MIX_GROUP; 192 multi->controls[i].mix_control.master = EMU_MULTI_CONTROL_MASTERID; 193 multi->controls[i].mix_control.string = string; 194 if (name) 195 strcpy(multi->controls[i].mix_control.name, name); 196 197 return multi->controls[i].mix_control.id; 198 } 199 200 201 static status_t 202 auich_create_controls_list(multi_dev *multi) 203 { 204 uint32 i = 0, index = 0, count, id, parent, parent2, parent3; 205 const ac97_source_info *info; 206 207 /* AC97 Mixer */ 208 parent = auich_create_group_control(multi, &index, 0, 0, "AC97 mixer"); 209 210 count = source_info_size; 211 //Note that we ignore first item in source_info 212 //It's for recording, but do match this with ac97.c's source_info 213 for (i = 1; i < count ; i++) { 214 info = &source_info[i]; 215 PRINT(("name : %s\n", info->name)); 216 217 parent2 = auich_create_group_control(multi, &index, parent, 0, info->name); 218 219 if (info->type & B_MIX_GAIN) { 220 if (info->type & B_MIX_MUTE) { 221 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 222 multi->controls[index].mix_control.flags = B_MULTI_MIX_ENABLE; 223 multi->controls[index].mix_control.master = EMU_MULTI_CONTROL_MASTERID; 224 multi->controls[index].mix_control.parent = parent2; 225 multi->controls[index].mix_control.string = S_MUTE; 226 multi->controls[index].cookie = info; 227 multi->controls[index].type = B_MIX_MUTE; 228 multi->controls[index].get = &auich_ac97_get_mix; 229 multi->controls[index].set = &auich_ac97_set_mix; 230 index++; 231 } 232 233 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 234 multi->controls[index].mix_control.flags = B_MULTI_MIX_GAIN; 235 multi->controls[index].mix_control.master = EMU_MULTI_CONTROL_MASTERID; 236 multi->controls[index].mix_control.parent = parent2; 237 strcpy(multi->controls[index].mix_control.name, info->name); 238 multi->controls[index].mix_control.u.gain.min_gain = info->min_gain; 239 multi->controls[index].mix_control.u.gain.max_gain = info->max_gain; 240 multi->controls[index].mix_control.u.gain.granularity = info->granularity; 241 multi->controls[index].cookie = info; 242 multi->controls[index].type = B_MIX_GAIN; 243 multi->controls[index].get = &auich_ac97_get_mix; 244 multi->controls[index].set = &auich_ac97_set_mix; 245 id = multi->controls[index].mix_control.id; 246 index++; 247 248 if (info->type & B_MIX_STEREO) { 249 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 250 multi->controls[index].mix_control.flags = B_MULTI_MIX_GAIN; 251 multi->controls[index].mix_control.master = id; 252 multi->controls[index].mix_control.parent = parent2; 253 strcpy(multi->controls[index].mix_control.name, info->name); 254 multi->controls[index].mix_control.u.gain.min_gain = info->min_gain; 255 multi->controls[index].mix_control.u.gain.max_gain = info->max_gain; 256 multi->controls[index].mix_control.u.gain.granularity = info->granularity; 257 multi->controls[index].cookie = info; 258 multi->controls[index].type = B_MIX_GAIN; 259 multi->controls[index].get = &auich_ac97_get_mix; 260 multi->controls[index].set = &auich_ac97_set_mix; 261 index++; 262 } 263 264 if (info->type & B_MIX_MICBOOST) { 265 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 266 multi->controls[index].mix_control.flags = B_MULTI_MIX_ENABLE; 267 multi->controls[index].mix_control.master = EMU_MULTI_CONTROL_MASTERID; 268 multi->controls[index].mix_control.parent = parent2; 269 strcpy(multi->controls[index].mix_control.name, "+20 dB"); 270 multi->controls[index].cookie = info; 271 multi->controls[index].type = B_MIX_MICBOOST; 272 multi->controls[index].get = &auich_ac97_get_mix; 273 multi->controls[index].set = &auich_ac97_set_mix; 274 index++; 275 } 276 } 277 } 278 279 /* AC97 Record */ 280 parent = auich_create_group_control(multi, &index, 0, 0, "Recording"); 281 282 info = &source_info[0]; 283 PRINT(("name : %s\n", info->name)); 284 285 parent2 = auich_create_group_control(multi, &index, parent, 0, info->name); 286 287 if (info->type & B_MIX_GAIN) { 288 if (info->type & B_MIX_MUTE) { 289 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 290 multi->controls[index].mix_control.flags = B_MULTI_MIX_ENABLE; 291 multi->controls[index].mix_control.master = EMU_MULTI_CONTROL_MASTERID; 292 multi->controls[index].mix_control.parent = parent2; 293 multi->controls[index].mix_control.string = S_MUTE; 294 multi->controls[index].cookie = info; 295 multi->controls[index].type = B_MIX_MUTE; 296 multi->controls[index].get = &auich_ac97_get_mix; 297 multi->controls[index].set = &auich_ac97_set_mix; 298 index++; 299 } 300 301 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 302 multi->controls[index].mix_control.flags = B_MULTI_MIX_GAIN; 303 multi->controls[index].mix_control.master = EMU_MULTI_CONTROL_MASTERID; 304 multi->controls[index].mix_control.parent = parent2; 305 strcpy(multi->controls[index].mix_control.name, info->name); 306 multi->controls[index].mix_control.u.gain.min_gain = info->min_gain; 307 multi->controls[index].mix_control.u.gain.max_gain = info->max_gain; 308 multi->controls[index].mix_control.u.gain.granularity = info->granularity; 309 multi->controls[index].cookie = info; 310 multi->controls[index].type = B_MIX_GAIN; 311 multi->controls[index].get = &auich_ac97_get_mix; 312 multi->controls[index].set = &auich_ac97_set_mix; 313 id = multi->controls[index].mix_control.id; 314 index++; 315 316 if (info->type & B_MIX_STEREO) { 317 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 318 multi->controls[index].mix_control.flags = B_MULTI_MIX_GAIN; 319 multi->controls[index].mix_control.master = id; 320 multi->controls[index].mix_control.parent = parent2; 321 strcpy(multi->controls[index].mix_control.name, info->name); 322 multi->controls[index].mix_control.u.gain.min_gain = info->min_gain; 323 multi->controls[index].mix_control.u.gain.max_gain = info->max_gain; 324 multi->controls[index].mix_control.u.gain.granularity = info->granularity; 325 multi->controls[index].cookie = info; 326 multi->controls[index].type = B_MIX_GAIN; 327 multi->controls[index].get = &auich_ac97_get_mix; 328 multi->controls[index].set = &auich_ac97_set_mix; 329 index++; 330 } 331 332 if (info->type & B_MIX_RECORDMUX) { 333 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 334 multi->controls[index].mix_control.flags = B_MULTI_MIX_MUX; 335 multi->controls[index].mix_control.parent = parent2; 336 strcpy(multi->controls[index].mix_control.name, "Record mux"); 337 multi->controls[index].cookie = info; 338 multi->controls[index].type = B_MIX_MUX; 339 multi->controls[index].get = &auich_ac97_get_mix; 340 multi->controls[index].set = &auich_ac97_set_mix; 341 parent3 = multi->controls[index].mix_control.id; 342 index++; 343 344 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 345 multi->controls[index].mix_control.flags = B_MULTI_MIX_MUX_VALUE; 346 multi->controls[index].mix_control.parent = parent3; 347 multi->controls[index].mix_control.string = S_MIC; 348 index++; 349 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 350 multi->controls[index].mix_control.flags = B_MULTI_MIX_MUX_VALUE; 351 multi->controls[index].mix_control.parent = parent3; 352 strcpy(multi->controls[index].mix_control.name, "CD in"); 353 index++; 354 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 355 multi->controls[index].mix_control.flags = B_MULTI_MIX_MUX_VALUE; 356 multi->controls[index].mix_control.parent = parent3; 357 strcpy(multi->controls[index].mix_control.name, "Video in"); 358 index++; 359 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 360 multi->controls[index].mix_control.flags = B_MULTI_MIX_MUX_VALUE; 361 multi->controls[index].mix_control.parent = parent3; 362 strcpy(multi->controls[index].mix_control.name, "Aux in"); 363 index++; 364 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 365 multi->controls[index].mix_control.flags = B_MULTI_MIX_MUX_VALUE; 366 multi->controls[index].mix_control.parent = parent3; 367 strcpy(multi->controls[index].mix_control.name, "Line in"); 368 index++; 369 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 370 multi->controls[index].mix_control.flags = B_MULTI_MIX_MUX_VALUE; 371 multi->controls[index].mix_control.parent = parent3; 372 multi->controls[index].mix_control.string = S_STEREO_MIX; 373 index++; 374 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 375 multi->controls[index].mix_control.flags = B_MULTI_MIX_MUX_VALUE; 376 multi->controls[index].mix_control.parent = parent3; 377 multi->controls[index].mix_control.string = S_MONO_MIX; 378 index++; 379 multi->controls[index].mix_control.id = EMU_MULTI_CONTROL_FIRSTID + index; 380 multi->controls[index].mix_control.flags = B_MULTI_MIX_MUX_VALUE; 381 multi->controls[index].mix_control.parent = parent3; 382 strcpy(multi->controls[index].mix_control.name, "TAD"); 383 index++; 384 } 385 } 386 387 multi->control_count = index; 388 PRINT(("multi->control_count %" B_PRIu32 "\n", multi->control_count)); 389 return B_OK; 390 } 391 392 393 static status_t 394 auich_get_mix(auich_dev *card, multi_mix_value_info * mmvi) 395 { 396 int32 i, id; 397 multi_mixer_control *control = NULL; 398 for (i = 0; i < mmvi->item_count; i++) { 399 id = mmvi->values[i].id - EMU_MULTI_CONTROL_FIRSTID; 400 if (id < 0 || id >= card->multi.control_count) { 401 PRINT(("auich_get_mix : " 402 "invalid control id requested : %" B_PRIi32 "\n", id)); 403 continue; 404 } 405 control = &card->multi.controls[id]; 406 407 if (control->mix_control.flags & B_MULTI_MIX_GAIN) { 408 if (control->get) { 409 float values[2]; 410 control->get(card, control->cookie, control->type, values); 411 if (control->mix_control.master == EMU_MULTI_CONTROL_MASTERID) 412 mmvi->values[i].u.gain = values[0]; 413 else 414 mmvi->values[i].u.gain = values[1]; 415 } 416 } 417 418 if (control->mix_control.flags & B_MULTI_MIX_ENABLE && control->get) { 419 float values[1]; 420 control->get(card, control->cookie, control->type, values); 421 mmvi->values[i].u.enable = (values[0] == 1.0); 422 } 423 424 if (control->mix_control.flags & B_MULTI_MIX_MUX && control->get) { 425 float values[1]; 426 control->get(card, control->cookie, control->type, values); 427 mmvi->values[i].u.mux = (int32)values[0]; 428 } 429 } 430 return B_OK; 431 } 432 433 434 static status_t 435 auich_set_mix(auich_dev *card, multi_mix_value_info * mmvi) 436 { 437 int32 i, id; 438 multi_mixer_control *control = NULL; 439 for (i = 0; i < mmvi->item_count; i++) { 440 id = mmvi->values[i].id - EMU_MULTI_CONTROL_FIRSTID; 441 if (id < 0 || id >= card->multi.control_count) { 442 PRINT(("auich_set_mix : " 443 "invalid control id requested : %" B_PRIi32 "\n", id)); 444 continue; 445 } 446 control = &card->multi.controls[id]; 447 448 if (control->mix_control.flags & B_MULTI_MIX_GAIN) { 449 multi_mixer_control *control2 = NULL; 450 if (i+1<mmvi->item_count) { 451 id = mmvi->values[i + 1].id - EMU_MULTI_CONTROL_FIRSTID; 452 if (id < 0 || id >= card->multi.control_count) { 453 PRINT(("auich_set_mix : " 454 "invalid control id requested : %" B_PRIi32 "\n", id)); 455 } else { 456 control2 = &card->multi.controls[id]; 457 if (control2->mix_control.master != control->mix_control.id) 458 control2 = NULL; 459 } 460 } 461 462 if (control->set) { 463 float values[2]; 464 values[0] = 0.0; 465 values[1] = 0.0; 466 467 if (control->mix_control.master == EMU_MULTI_CONTROL_MASTERID) 468 values[0] = mmvi->values[i].u.gain; 469 else 470 values[1] = mmvi->values[i].u.gain; 471 472 if (control2 && control2->mix_control.master != EMU_MULTI_CONTROL_MASTERID) 473 values[1] = mmvi->values[i+1].u.gain; 474 475 control->set(card, control->cookie, control->type, values); 476 } 477 478 if (control2) 479 i++; 480 } 481 482 if (control->mix_control.flags & B_MULTI_MIX_ENABLE && control->set) { 483 float values[1]; 484 485 values[0] = mmvi->values[i].u.enable ? 1.0 : 0.0; 486 control->set(card, control->cookie, control->type, values); 487 } 488 489 if (control->mix_control.flags & B_MULTI_MIX_MUX && control->set) { 490 float values[1]; 491 492 values[0] = (float)mmvi->values[i].u.mux; 493 control->set(card, control->cookie, control->type, values); 494 } 495 } 496 return B_OK; 497 } 498 499 500 static status_t 501 auich_list_mix_controls(auich_dev *card, multi_mix_control_info * mmci) 502 { 503 multi_mix_control *mmc; 504 int32 i; 505 506 mmc = mmci->controls; 507 if (mmci->control_count < 24) 508 return B_ERROR; 509 510 if (auich_create_controls_list(&card->multi) < B_OK) 511 return B_ERROR; 512 for (i = 0; i < card->multi.control_count; i++) { 513 mmc[i] = card->multi.controls[i].mix_control; 514 } 515 516 mmci->control_count = card->multi.control_count; 517 return B_OK; 518 } 519 520 521 static status_t 522 auich_list_mix_connections(auich_dev *card, multi_mix_connection_info * data) 523 { 524 return B_ERROR; 525 } 526 527 528 static status_t 529 auich_list_mix_channels(auich_dev *card, multi_mix_channel_info *data) 530 { 531 return B_ERROR; 532 } 533 534 /*multi_channel_info chans[] = { 535 { 0, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, 0 }, 536 { 1, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, 0 }, 537 { 2, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, 0 }, 538 { 3, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, 0 }, 539 { 4, B_MULTI_INPUT_CHANNEL, B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, 0 }, 540 { 5, B_MULTI_INPUT_CHANNEL, B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, 0 }, 541 { 6, B_MULTI_INPUT_CHANNEL, B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, 0 }, 542 { 7, B_MULTI_INPUT_CHANNEL, B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, 0 }, 543 { 8, B_MULTI_OUTPUT_BUS, B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO }, 544 { 9, B_MULTI_OUTPUT_BUS, B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO }, 545 { 10, B_MULTI_INPUT_BUS, B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO }, 546 { 11, B_MULTI_INPUT_BUS, B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO }, 547 };*/ 548 549 /*multi_channel_info chans[] = { 550 { 0, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, 0 }, 551 { 1, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, 0 }, 552 { 2, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_LEFT | B_CHANNEL_SURROUND_BUS, 0 }, 553 { 3, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_RIGHT | B_CHANNEL_SURROUND_BUS, 0 }, 554 { 4, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_REARLEFT | B_CHANNEL_SURROUND_BUS, 0 }, 555 { 5, B_MULTI_OUTPUT_CHANNEL, B_CHANNEL_REARRIGHT | B_CHANNEL_SURROUND_BUS, 0 }, 556 { 6, B_MULTI_INPUT_CHANNEL, B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, 0 }, 557 { 7, B_MULTI_INPUT_CHANNEL, B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, 0 }, 558 { 8, B_MULTI_INPUT_CHANNEL, B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, 0 }, 559 { 9, B_MULTI_INPUT_CHANNEL, B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, 0 }, 560 { 10, B_MULTI_OUTPUT_BUS, B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO }, 561 { 11, B_MULTI_OUTPUT_BUS, B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO }, 562 { 12, B_MULTI_INPUT_BUS, B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO }, 563 { 13, B_MULTI_INPUT_BUS, B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS, B_CHANNEL_MINI_JACK_STEREO }, 564 };*/ 565 566 567 static void 568 auich_create_channels_list(multi_dev *multi) 569 { 570 auich_stream *stream; 571 uint32 index, i, mode, designations; 572 multi_channel_info *chans; 573 uint32 chan_designations[] = { 574 B_CHANNEL_LEFT, 575 B_CHANNEL_RIGHT, 576 B_CHANNEL_REARLEFT, 577 B_CHANNEL_REARRIGHT, 578 B_CHANNEL_CENTER, 579 B_CHANNEL_SUB 580 }; 581 582 chans = multi->chans; 583 index = 0; 584 585 for (mode=AUICH_USE_PLAY; mode!=-1; 586 mode = (mode == AUICH_USE_PLAY) ? AUICH_USE_RECORD : -1) { 587 LIST_FOREACH(stream, &((auich_dev*)multi->card)->streams, next) { 588 if ((stream->use & mode) == 0) 589 continue; 590 591 if (stream->channels == 2) 592 designations = B_CHANNEL_STEREO_BUS; 593 else 594 designations = B_CHANNEL_SURROUND_BUS; 595 596 for (i = 0; i < stream->channels; i++) { 597 chans[index].channel_id = index; 598 chans[index].kind = (mode == AUICH_USE_PLAY) ? B_MULTI_OUTPUT_CHANNEL : B_MULTI_INPUT_CHANNEL; 599 chans[index].designations = designations | chan_designations[i]; 600 chans[index].connectors = 0; 601 index++; 602 } 603 } 604 605 if (mode==AUICH_USE_PLAY) { 606 multi->output_channel_count = index; 607 } else { 608 multi->input_channel_count = index - multi->output_channel_count; 609 } 610 } 611 612 chans[index].channel_id = index; 613 chans[index].kind = B_MULTI_OUTPUT_BUS; 614 chans[index].designations = B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS; 615 chans[index].connectors = B_CHANNEL_MINI_JACK_STEREO; 616 index++; 617 618 chans[index].channel_id = index; 619 chans[index].kind = B_MULTI_OUTPUT_BUS; 620 chans[index].designations = B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS; 621 chans[index].connectors = B_CHANNEL_MINI_JACK_STEREO; 622 index++; 623 624 multi->output_bus_channel_count = index - multi->output_channel_count 625 - multi->input_channel_count; 626 627 chans[index].channel_id = index; 628 chans[index].kind = B_MULTI_INPUT_BUS; 629 chans[index].designations = B_CHANNEL_LEFT | B_CHANNEL_STEREO_BUS; 630 chans[index].connectors = B_CHANNEL_MINI_JACK_STEREO; 631 index++; 632 633 chans[index].channel_id = index; 634 chans[index].kind = B_MULTI_INPUT_BUS; 635 chans[index].designations = B_CHANNEL_RIGHT | B_CHANNEL_STEREO_BUS; 636 chans[index].connectors = B_CHANNEL_MINI_JACK_STEREO; 637 index++; 638 639 multi->input_bus_channel_count = index - multi->output_channel_count 640 - multi->input_channel_count - multi->output_bus_channel_count; 641 642 multi->aux_bus_channel_count = 0; 643 } 644 645 646 static status_t 647 auich_get_description(auich_dev *card, multi_description *data) 648 { 649 uint32 size; 650 651 data->interface_version = B_CURRENT_INTERFACE_VERSION; 652 data->interface_minimum = B_CURRENT_INTERFACE_VERSION; 653 654 switch(card->info.vendor_id) { 655 case INTEL_VENDOR_ID: 656 strncpy(data->friendly_name, FRIENDLY_NAME_ICH, 32); 657 break; 658 case SIS_VENDOR_ID: 659 strncpy(data->friendly_name, FRIENDLY_NAME_SIS, 32); 660 break; 661 case NVIDIA_VENDOR_ID: 662 strncpy(data->friendly_name, FRIENDLY_NAME_NVIDIA, 32); 663 break; 664 case AMD_VENDOR_ID: 665 strncpy(data->friendly_name, FRIENDLY_NAME_AMD, 32); 666 break; 667 } 668 669 strcpy(data->vendor_info, AUTHOR); 670 671 /*data->output_channel_count = 6; 672 data->input_channel_count = 4; 673 data->output_bus_channel_count = 2; 674 data->input_bus_channel_count = 2; 675 data->aux_bus_channel_count = 0;*/ 676 677 data->output_channel_count = card->multi.output_channel_count; 678 data->input_channel_count = card->multi.input_channel_count; 679 data->output_bus_channel_count = card->multi.output_bus_channel_count; 680 data->input_bus_channel_count = card->multi.input_bus_channel_count; 681 data->aux_bus_channel_count = card->multi.aux_bus_channel_count; 682 683 size = card->multi.output_channel_count + card->multi.input_channel_count 684 + card->multi.output_bus_channel_count + card->multi.input_bus_channel_count 685 + card->multi.aux_bus_channel_count; 686 687 // for each channel, starting with the first output channel, 688 // then the second, third..., followed by the first input 689 // channel, second, third, ..., followed by output bus 690 // channels and input bus channels and finally auxillary channels, 691 692 LOG(("request_channel_count = %d\n",data->request_channel_count)); 693 if (data->request_channel_count >= size) { 694 LOG(("copying data\n")); 695 memcpy(data->channels, card->multi.chans, size * sizeof(card->multi.chans[0])); 696 } 697 698 switch (current_settings.sample_rate) { 699 case 48000: data->output_rates = data->input_rates = B_SR_48000; break; 700 case 44100: data->output_rates = data->input_rates = B_SR_44100; break; 701 } 702 data->min_cvsr_rate = 0; 703 data->max_cvsr_rate = 48000; 704 705 data->output_formats = B_FMT_16BIT; 706 data->input_formats = B_FMT_16BIT; 707 data->lock_sources = B_MULTI_LOCK_INTERNAL; 708 data->timecode_sources = 0; 709 data->interface_flags = B_MULTI_INTERFACE_PLAYBACK | B_MULTI_INTERFACE_RECORD; 710 data->start_latency = 3000; 711 712 strcpy(data->control_panel,""); 713 714 return B_OK; 715 } 716 717 718 static status_t 719 auich_get_enabled_channels(auich_dev *card, multi_channel_enable *data) 720 { 721 B_SET_CHANNEL(data->enable_bits, 0, true); 722 B_SET_CHANNEL(data->enable_bits, 1, true); 723 B_SET_CHANNEL(data->enable_bits, 2, true); 724 B_SET_CHANNEL(data->enable_bits, 3, true); 725 data->lock_source = B_MULTI_LOCK_INTERNAL; 726 /* 727 uint32 lock_source; 728 int32 lock_data; 729 uint32 timecode_source; 730 uint32 * connectors; 731 */ 732 return B_OK; 733 } 734 735 736 static status_t 737 auich_get_global_format(auich_dev *card, multi_format_info *data) 738 { 739 data->output_latency = 0; 740 data->input_latency = 0; 741 data->timecode_kind = 0; 742 switch (current_settings.sample_rate) { 743 case 48000: 744 data->input.rate = data->output.rate = B_SR_48000; 745 data->input.cvsr = data->output.cvsr = 48000; 746 break; 747 case 44100: 748 data->input.rate = data->output.rate = B_SR_44100; 749 data->input.cvsr = data->output.cvsr = 44100; 750 break; 751 } 752 data->input.format = data->output.format = B_FMT_16BIT; 753 return B_OK; 754 } 755 756 757 static status_t 758 auich_set_global_format(auich_dev *card, multi_format_info* data) 759 { 760 // TODO: it looks like we're not supposed to fail; fix this! 761 return B_OK; 762 } 763 764 765 static status_t 766 auich_get_buffers(auich_dev *card, multi_buffer_list *data) 767 { 768 uint8 i, j, pchannels, rchannels, bufcount; 769 770 LOG(("flags = %#x\n",data->flags)); 771 LOG(("request_playback_buffers = %#x\n",data->request_playback_buffers)); 772 LOG(("request_playback_channels = %#x\n",data->request_playback_channels)); 773 LOG(("request_playback_buffer_size = %#x\n",data->request_playback_buffer_size)); 774 LOG(("request_record_buffers = %#x\n",data->request_record_buffers)); 775 LOG(("request_record_channels = %#x\n",data->request_record_channels)); 776 LOG(("request_record_buffer_size = %#x\n",data->request_record_buffer_size)); 777 778 pchannels = card->pstream->channels; 779 rchannels = card->rstream->channels; 780 781 if (data->request_playback_buffers < current_settings.buffer_count || 782 data->request_playback_channels < (pchannels) || 783 data->request_record_buffers < current_settings.buffer_count || 784 data->request_record_channels < (rchannels)) { 785 LOG(("not enough channels/buffers\n")); 786 } 787 788 ASSERT(current_settings.buffer_count == 2); 789 790 data->flags = B_MULTI_BUFFER_PLAYBACK | B_MULTI_BUFFER_RECORD; // XXX ??? 791 // data->flags = 0; 792 793 data->return_playback_buffers = current_settings.buffer_count; /* playback_buffers[b][] */ 794 data->return_playback_channels = pchannels; /* playback_buffers[][c] */ 795 data->return_playback_buffer_size = current_settings.buffer_frames; /* frames */ 796 797 bufcount = current_settings.buffer_count; 798 if (bufcount > data->request_playback_buffers) 799 bufcount = data->request_playback_buffers; 800 801 for (i = 0; i < bufcount; i++) { 802 struct buffer_desc descs[data->return_playback_channels]; 803 for (j=0; j<pchannels; j++) 804 auich_stream_get_nth_buffer(card->pstream, j, i, 805 &descs[j].base, 806 &descs[j].stride); 807 if (!IS_USER_ADDRESS(data->playback_buffers[i]) 808 || user_memcpy(data->playback_buffers[i], descs, sizeof(descs)) 809 < B_OK) { 810 return B_BAD_ADDRESS; 811 } 812 } 813 data->return_record_buffers = current_settings.buffer_count; 814 data->return_record_channels = rchannels; 815 data->return_record_buffer_size = current_settings.buffer_frames; /* frames */ 816 817 bufcount = current_settings.buffer_count; 818 if (bufcount > data->request_record_buffers) 819 bufcount = data->request_record_buffers; 820 821 for (i = 0; i < bufcount; i++) { 822 struct buffer_desc descs[data->return_record_channels]; 823 for (j=0; j<rchannels; j++) 824 auich_stream_get_nth_buffer(card->rstream, j, i, 825 &descs[j].base, 826 &descs[j].stride); 827 if (!IS_USER_ADDRESS(data->record_buffers[i]) 828 || user_memcpy(data->record_buffers[i], descs, sizeof(descs)) 829 < B_OK) { 830 return B_BAD_ADDRESS; 831 } 832 } 833 return B_OK; 834 } 835 836 837 static void 838 auich_play_inth(void* inthparams) 839 { 840 auich_stream *stream = (auich_stream *)inthparams; 841 //int32 count; 842 843 acquire_spinlock(&slock); 844 stream->real_time = system_time(); 845 stream->frames_count += current_settings.buffer_frames; 846 stream->buffer_cycle = (stream->trigblk 847 + stream->blkmod - 1) % stream->blkmod; 848 stream->update_needed = true; 849 release_spinlock(&slock); 850 851 TRACE(("auich_play_inth : cycle : %d\n", stream->buffer_cycle)); 852 853 //get_sem_count(stream->card->buffer_ready_sem, &count); 854 //if (count <= 0) 855 release_sem_etc(stream->card->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE); 856 } 857 858 859 static void 860 auich_record_inth(void* inthparams) 861 { 862 auich_stream *stream = (auich_stream *)inthparams; 863 //int32 count; 864 865 acquire_spinlock(&slock); 866 stream->real_time = system_time(); 867 stream->frames_count += current_settings.buffer_frames; 868 stream->buffer_cycle = (stream->trigblk 869 + stream->blkmod - 1) % stream->blkmod; 870 stream->update_needed = true; 871 release_spinlock(&slock); 872 873 TRACE(("auich_record_inth : cycle : %d\n", stream->buffer_cycle)); 874 875 //get_sem_count(stream->card->buffer_ready_sem, &count); 876 //if (count <= 0) 877 release_sem_etc(stream->card->buffer_ready_sem, 1, B_DO_NOT_RESCHEDULE); 878 } 879 880 881 static status_t 882 auich_buffer_exchange(auich_dev *card, multi_buffer_info *data) 883 { 884 cpu_status status; 885 auich_stream *pstream, *rstream; 886 multi_buffer_info buffer_info; 887 888 #ifdef __HAIKU__ 889 if (user_memcpy(&buffer_info, data, sizeof(buffer_info)) < B_OK) 890 return B_BAD_ADDRESS; 891 #else 892 memcpy(&buffer_info, data, sizeof(buffer_info)); 893 #endif 894 895 buffer_info.flags = B_MULTI_BUFFER_PLAYBACK | B_MULTI_BUFFER_RECORD; 896 897 if (!(card->pstream->state & AUICH_STATE_STARTED)) 898 auich_stream_start(card->pstream, auich_play_inth, card->pstream); 899 900 if (!(card->rstream->state & AUICH_STATE_STARTED)) 901 auich_stream_start(card->rstream, auich_record_inth, card->rstream); 902 903 if (acquire_sem_etc(card->buffer_ready_sem, 1, B_RELATIVE_TIMEOUT | B_CAN_INTERRUPT, 50000) 904 == B_TIMED_OUT) { 905 LOG(("buffer_exchange timeout ff\n")); 906 } 907 908 status = lock(); 909 910 LIST_FOREACH(pstream, &card->streams, next) { 911 if ((pstream->use & AUICH_USE_PLAY) == 0 || 912 (pstream->state & AUICH_STATE_STARTED) == 0) 913 continue; 914 if (pstream->update_needed) 915 break; 916 } 917 918 LIST_FOREACH(rstream, &card->streams, next) { 919 if ((rstream->use & AUICH_USE_RECORD) == 0 || 920 (rstream->state & AUICH_STATE_STARTED) == 0) 921 continue; 922 if (rstream->update_needed) 923 break; 924 } 925 926 if (!pstream) 927 pstream = card->pstream; 928 if (!rstream) 929 rstream = card->rstream; 930 931 /* do playback */ 932 buffer_info.playback_buffer_cycle = pstream->buffer_cycle; 933 buffer_info.played_real_time = pstream->real_time; 934 buffer_info.played_frames_count = pstream->frames_count; 935 buffer_info._reserved_0 = pstream->first_channel; 936 pstream->update_needed = false; 937 938 /* do record */ 939 buffer_info.record_buffer_cycle = rstream->buffer_cycle; 940 buffer_info.recorded_frames_count = rstream->frames_count; 941 buffer_info.recorded_real_time = rstream->real_time; 942 buffer_info._reserved_1 = rstream->first_channel; 943 rstream->update_needed = false; 944 unlock(status); 945 946 #ifdef __HAIKU__ 947 if (user_memcpy(data, &buffer_info, sizeof(buffer_info)) < B_OK) 948 return B_BAD_ADDRESS; 949 #else 950 memcpy(data, &buffer_info, sizeof(buffer_info)); 951 #endif 952 953 //TRACE(("buffer_exchange ended\n")); 954 return B_OK; 955 } 956 957 958 static status_t 959 auich_buffer_force_stop(auich_dev *card) 960 { 961 //auich_voice_halt(card->pvoice); 962 return B_OK; 963 } 964 965 966 #define cookie_type auich_dev 967 #define get_description auich_get_description 968 #define get_enabled_channels auich_get_enabled_channels 969 #define get_global_format auich_get_global_format 970 #define set_global_format auich_set_global_format 971 #define list_mix_channels auich_list_mix_channels 972 #define list_mix_controls auich_list_mix_controls 973 #define list_mix_connections auich_list_mix_connections 974 #define get_mix auich_get_mix 975 #define set_mix auich_set_mix 976 #define get_buffers auich_get_buffers 977 #define buffer_exchange auich_buffer_exchange 978 #define buffer_force_stop auich_buffer_force_stop 979 #include "../generic/multi.c" 980 981 982 static status_t 983 auich_multi_control(void *cookie, uint32 op, void *arg, size_t length) 984 { 985 auich_dev *card = (auich_dev *)cookie; 986 987 return multi_audio_control_generic(card, op, arg, length); 988 } 989 990 static status_t auich_open(const char *name, uint32 flags, void** cookie); 991 static status_t auich_close(void* cookie); 992 static status_t auich_free(void* cookie); 993 static status_t auich_control(void* cookie, uint32 op, void* arg, size_t len); 994 static status_t auich_read(void* cookie, off_t position, void *buf, size_t* num_bytes); 995 static status_t auich_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes); 996 997 device_hooks multi_hooks = { 998 auich_open, /* -> open entry point */ 999 auich_close, /* -> close entry point */ 1000 auich_free, /* -> free cookie */ 1001 auich_control, /* -> control entry point */ 1002 auich_read, /* -> read entry point */ 1003 auich_write, /* -> write entry point */ 1004 NULL, /* start select */ 1005 NULL, /* stop select */ 1006 NULL, /* scatter-gather read from the device */ 1007 NULL /* scatter-gather write to the device */ 1008 }; 1009 1010 1011 static status_t 1012 auich_open(const char *name, uint32 flags, void** cookie) 1013 { 1014 auich_dev *card = NULL; 1015 void *settings_handle; 1016 int ix; 1017 1018 LOG(("open()\n")); 1019 1020 for (ix=0; ix<num_cards; ix++) { 1021 if (!strcmp(cards[ix].name, name)) { 1022 card = &cards[ix]; 1023 } 1024 } 1025 1026 if (card == NULL) { 1027 LOG(("open() card not found %s\n", name)); 1028 for (ix=0; ix<num_cards; ix++) { 1029 LOG(("open() card available %s\n", cards[ix].name)); 1030 } 1031 return B_ERROR; 1032 } 1033 1034 LOG(("open() got card\n")); 1035 1036 if (card->pstream !=NULL) 1037 return B_ERROR; 1038 if (card->rstream !=NULL) 1039 return B_ERROR; 1040 1041 *cookie = card; 1042 card->multi.card = card; 1043 1044 // get driver settings 1045 settings_handle = load_driver_settings(AUICH_SETTINGS); 1046 if (settings_handle != NULL) { 1047 const char *item; 1048 char *end; 1049 uint32 value; 1050 1051 item = get_driver_parameter (settings_handle, "sample_rate", "48000", "48000"); 1052 value = strtoul (item, &end, 0); 1053 if (*end == '\0') 1054 current_settings.sample_rate = value; 1055 1056 item = get_driver_parameter (settings_handle, "buffer_frames", "256", "256"); 1057 value = strtoul (item, &end, 0); 1058 if (*end == '\0') 1059 current_settings.buffer_frames = value; 1060 1061 item = get_driver_parameter (settings_handle, "buffer_count", "4", "4"); 1062 value = strtoul (item, &end, 0); 1063 if (*end == '\0') 1064 current_settings.buffer_count = value; 1065 1066 unload_driver_settings(settings_handle); 1067 } 1068 1069 LOG(("stream_new\n")); 1070 1071 card->rstream = auich_stream_new(card, AUICH_USE_RECORD, current_settings.buffer_frames, current_settings.buffer_count); 1072 card->pstream = auich_stream_new(card, AUICH_USE_PLAY, current_settings.buffer_frames, current_settings.buffer_count); 1073 1074 card->buffer_ready_sem = create_sem(0, "pbuffer ready"); 1075 1076 LOG(("stream_setaudio\n")); 1077 1078 auich_stream_set_audioparms(card->pstream, 2, true, current_settings.sample_rate); 1079 auich_stream_set_audioparms(card->rstream, 2, true, current_settings.sample_rate); 1080 1081 card->pstream->first_channel = 0; 1082 card->rstream->first_channel = 2; 1083 1084 auich_stream_commit_parms(card->pstream); 1085 auich_stream_commit_parms(card->rstream); 1086 1087 auich_create_channels_list(&card->multi); 1088 1089 return B_OK; 1090 } 1091 1092 1093 static status_t 1094 auich_close(void* cookie) 1095 { 1096 //auich_dev *card = cookie; 1097 LOG(("close()\n")); 1098 1099 return B_OK; 1100 } 1101 1102 1103 static status_t 1104 auich_free(void* cookie) 1105 { 1106 auich_dev *card = cookie; 1107 auich_stream *stream; 1108 LOG(("free()\n")); 1109 1110 if (card->buffer_ready_sem > B_OK) 1111 delete_sem(card->buffer_ready_sem); 1112 1113 LIST_FOREACH(stream, &card->streams, next) { 1114 auich_stream_halt(stream); 1115 } 1116 1117 while (!LIST_EMPTY(&card->streams)) { 1118 auich_stream_delete(LIST_FIRST(&card->streams)); 1119 } 1120 1121 card->pstream = NULL; 1122 card->rstream = NULL; 1123 1124 return B_OK; 1125 } 1126 1127 1128 static status_t 1129 auich_control(void* cookie, uint32 op, void* arg, size_t len) 1130 { 1131 return auich_multi_control(cookie, op, arg, len); 1132 } 1133 1134 1135 static status_t 1136 auich_read(void* cookie, off_t position, void *buf, size_t* num_bytes) 1137 { 1138 *num_bytes = 0; /* tell caller nothing was read */ 1139 return B_IO_ERROR; 1140 } 1141 1142 1143 static status_t 1144 auich_write(void* cookie, off_t position, const void* buffer, size_t* num_bytes) 1145 { 1146 *num_bytes = 0; /* tell caller nothing was written */ 1147 return B_IO_ERROR; 1148 } 1149