[25c98a8e] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Jan Vesely
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 | /** @addtogroup drvaudiosb16
|
---|
| 29 | * @{
|
---|
| 30 | */
|
---|
| 31 | /** @file
|
---|
| 32 | * Main routines of Creative Labs SoundBlaster 16 driver
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[9bd4615] | 35 | #include <ddf/driver.h>
|
---|
[25c98a8e] | 36 | #include <errno.h>
|
---|
| 37 | #include <audio_mixer_iface.h>
|
---|
| 38 |
|
---|
| 39 | #include "mixer.h"
|
---|
[9bd4615] | 40 | #include "sb16.h"
|
---|
| 41 |
|
---|
| 42 | static sb_mixer_t *fun_to_mixer(ddf_fun_t *fun)
|
---|
| 43 | {
|
---|
| 44 | sb16_t *sb = (sb16_t *)ddf_dev_data_get(ddf_fun_get_dev(fun));
|
---|
| 45 | return &sb->mixer;
|
---|
| 46 | }
|
---|
[25c98a8e] | 47 |
|
---|
[1433ecda] | 48 | static errno_t sb_get_info(ddf_fun_t *fun, const char **name, unsigned *items)
|
---|
[25c98a8e] | 49 | {
|
---|
[9bd4615] | 50 | sb_mixer_t *mixer = fun_to_mixer(fun);
|
---|
| 51 |
|
---|
[25c98a8e] | 52 | if (name)
|
---|
| 53 | *name = sb_mixer_type_str(mixer->type);
|
---|
| 54 | if (items)
|
---|
| 55 | *items = sb_mixer_get_control_item_count(mixer);
|
---|
| 56 |
|
---|
| 57 | return EOK;
|
---|
| 58 | }
|
---|
[1912b45] | 59 |
|
---|
[1433ecda] | 60 | static errno_t sb_get_item_info(ddf_fun_t *fun, unsigned item, const char **name,
|
---|
[1912b45] | 61 | unsigned *max_level)
|
---|
[25c98a8e] | 62 | {
|
---|
[9bd4615] | 63 | sb_mixer_t *mixer = fun_to_mixer(fun);
|
---|
| 64 | return sb_mixer_get_control_item_info(mixer, item, name, max_level);
|
---|
[25c98a8e] | 65 | }
|
---|
[1912b45] | 66 |
|
---|
[b7fd2a0] | 67 | static errno_t sb_set_item_level(ddf_fun_t *fun, unsigned item, unsigned value)
|
---|
[25c98a8e] | 68 | {
|
---|
[9bd4615] | 69 | sb_mixer_t *mixer = fun_to_mixer(fun);
|
---|
[1912b45] | 70 | return sb_mixer_set_control_item_value(mixer, item, value);
|
---|
[25c98a8e] | 71 | }
|
---|
[1912b45] | 72 |
|
---|
[b7fd2a0] | 73 | static errno_t sb_get_item_level(ddf_fun_t *fun, unsigned item, unsigned *value)
|
---|
[25c98a8e] | 74 | {
|
---|
[9bd4615] | 75 | sb_mixer_t *mixer = fun_to_mixer(fun);
|
---|
[1912b45] | 76 | return sb_mixer_get_control_item_value(mixer, item, value);
|
---|
[25c98a8e] | 77 | }
|
---|
| 78 |
|
---|
| 79 | audio_mixer_iface_t sb_mixer_iface = {
|
---|
| 80 | .get_info = sb_get_info,
|
---|
| 81 | .get_item_info = sb_get_item_info,
|
---|
| 82 |
|
---|
[1912b45] | 83 | .get_item_level = sb_get_item_level,
|
---|
| 84 | .set_item_level = sb_set_item_level,
|
---|
[25c98a8e] | 85 | };
|
---|
| 86 | /**
|
---|
| 87 | * @}
|
---|
| 88 | */
|
---|