source: mainline/uspace/drv/audio/sb16/mixer_iface.c@ 413225d

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 413225d was be51d73, checked in by Jan Vesely <jano.vesely@…>, 14 years ago

sb16: Implement volume set iface function.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * Copyright (c) 2011 Jan Vesely
3 * Copyright (c) 2011 Vojtech Horky
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29/** @addtogroup drvaudiosb16
30 * @{
31 */
32/** @file
33 * Main routines of Creative Labs SoundBlaster 16 driver
34 */
35
36#include <errno.h>
37#include <audio_mixer_iface.h>
38
39#include "mixer.h"
40
41static int sb_get_info(ddf_fun_t *fun, const char** name, unsigned *items)
42{
43 assert(fun);
44 assert(fun->driver_data);
45 const sb_mixer_t *mixer = fun->driver_data;
46 if (name)
47 *name = sb_mixer_type_str(mixer->type);
48 if (items)
49 *items = sb_mixer_get_control_item_count(mixer);
50
51 return EOK;
52}
53/*----------------------------------------------------------------------------*/
54static int sb_get_item_info(ddf_fun_t *fun, unsigned item, const char** name,
55 unsigned *channels)
56{
57 assert(fun);
58 assert(fun->driver_data);
59 const sb_mixer_t *mixer = fun->driver_data;
60 return
61 sb_mixer_get_control_item_info(mixer, item, name, channels);
62}
63/*----------------------------------------------------------------------------*/
64static int sb_get_channel_info(ddf_fun_t *fun, unsigned item, unsigned channel,
65 const char** name, unsigned *levels)
66{
67 assert(fun);
68 assert(fun->driver_data);
69 const sb_mixer_t *mixer = fun->driver_data;
70 return sb_mixer_get_channel_info(mixer, item, channel, name, levels);
71}
72/*----------------------------------------------------------------------------*/
73static int sb_channel_mute_set(ddf_fun_t *fun, unsigned item, unsigned channel,
74 bool mute)
75{
76 return ENOTSUP;
77}
78/*----------------------------------------------------------------------------*/
79static int sb_channel_mute_get(ddf_fun_t *fun, unsigned item, unsigned channel,
80 bool *mute)
81{
82 *mute = false;
83 return EOK;
84}
85/*----------------------------------------------------------------------------*/
86static int sb_channel_volume_set(ddf_fun_t *fun, unsigned item, unsigned channel,
87 unsigned volume)
88{
89 assert(fun);
90 assert(fun->driver_data);
91 const sb_mixer_t *mixer = fun->driver_data;
92 return sb_mixer_set_volume_level(mixer, item, channel, volume);
93}
94/*----------------------------------------------------------------------------*/
95static int sb_channel_volume_get(ddf_fun_t *fun, unsigned item, unsigned channel,
96 unsigned *level, unsigned *max)
97{
98 assert(fun);
99 assert(fun->driver_data);
100 const sb_mixer_t *mixer = fun->driver_data;
101 unsigned levels;
102 const int ret =
103 sb_mixer_get_channel_info(mixer, item, channel, NULL, &levels);
104 if (ret == EOK && max)
105 *max = --levels;
106 if (ret == EOK && level)
107 *level = sb_mixer_get_volume_level(mixer, item, channel);
108
109 return ret;
110}
111
112audio_mixer_iface_t sb_mixer_iface = {
113 .get_info = sb_get_info,
114 .get_item_info = sb_get_item_info,
115 .get_channel_info = sb_get_channel_info,
116
117 .channel_mute_set = sb_channel_mute_set,
118 .channel_mute_get = sb_channel_mute_get,
119
120 .channel_volume_set = sb_channel_volume_set,
121 .channel_volume_get = sb_channel_volume_get,
122
123};
124/**
125 * @}
126 */
Note: See TracBrowser for help on using the repository browser.