|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \file control/control.c
|
|
Packit |
4a16fb |
* \brief CTL interface - primitive controls
|
|
Packit |
4a16fb |
* \author Abramo Bagnara <abramo@alsa-project.org>
|
|
Packit |
4a16fb |
* \date 2000
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* CTL interface is designed to access primitive controls.
|
|
Packit |
4a16fb |
* See \ref control page for more details.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
/*
|
|
Packit |
4a16fb |
* Control Interface - main file
|
|
Packit |
4a16fb |
* Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This library is free software; you can redistribute it and/or modify
|
|
Packit |
4a16fb |
* it under the terms of the GNU Lesser General Public License as
|
|
Packit |
4a16fb |
* published by the Free Software Foundation; either version 2.1 of
|
|
Packit |
4a16fb |
* the License, or (at your option) any later version.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
4a16fb |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
4a16fb |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
4a16fb |
* GNU Lesser General Public License for more details.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
4a16fb |
* License along with this library; if not, write to the Free Software
|
|
Packit |
4a16fb |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/*! \page control Control interface
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
Control interface is designed to access primitive controls. There is
|
|
Packit |
4a16fb |
also interface notifying about control and structure changes.
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
\section control_general_overview General overview
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
In ALSA control feature, each sound card can have control elements. The elements
|
|
Packit |
4a16fb |
are managed according to below model.
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
- element set
|
|
Packit |
4a16fb |
- A set of elements with the same attribute (i.e. name, get/put operations).
|
|
Packit |
4a16fb |
Some element sets can be added to a sound card by drivers in kernel and
|
|
Packit |
4a16fb |
userspace applications.
|
|
Packit |
4a16fb |
- element
|
|
Packit |
4a16fb |
- An element can be identified by userspace applications. Each element has
|
|
Packit |
4a16fb |
own identical information.
|
|
Packit |
4a16fb |
- member
|
|
Packit |
4a16fb |
- An element includes some members to have a value. The value of each member
|
|
Packit |
4a16fb |
can be changed by both of userspace applications and drivers in kernel.
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
Each element can be identified by two ways; a combination of name and index, or
|
|
Packit |
4a16fb |
numerical number (numid).
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
The type of element set is one of integer, integerr64, boolean, enumerators,
|
|
Packit |
4a16fb |
bytes and IEC958 structure. This indicates the type of value for each member in
|
|
Packit |
4a16fb |
elements included in the element set.
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
When the value of member is changed, corresponding events are transferred to
|
|
Packit |
4a16fb |
userspace applications. The applications should subscribe any events in advance.
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
\section tlv_blob Supplemental data for elements in an element set
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
TLV feature is designed to transfer data in a shape of Type/Length/Value,
|
|
Packit |
4a16fb |
between a driver and any userspace applications. The main purpose is to attach
|
|
Packit |
4a16fb |
supplement information for elements to an element set; e.g. dB range.
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
At first, this feature was implemented to add pre-defined data readable to
|
|
Packit |
4a16fb |
userspace applications. Soon, it was extended to handle several operations;
|
|
Packit |
4a16fb |
read, write and command. The original implementation remains as the read
|
|
Packit |
4a16fb |
operation. The command operation allows drivers to have own implementations
|
|
Packit |
4a16fb |
against requests from userspace applications.
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
This feature was introduced to ALSA control feature in 2006, at commit
|
|
Packit |
4a16fb |
c7a0708a2362, corresponding to a series of work for Linux kernel (42750b04c5ba
|
|
Packit |
4a16fb |
and 8aa9b586e420).
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
There's no limitation about maximum size of the data, therefore it can be used
|
|
Packit |
4a16fb |
to deliver quite large arbitrary data from userspace to in-kernel drivers via
|
|
Packit |
4a16fb |
ALSA control character device. Focusing on this nature, as of 2016, some
|
|
Packit |
4a16fb |
in-kernel implementations utilize this feature for I/O operations. This is
|
|
Packit |
4a16fb |
against the original design.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
#include <stdio.h>
|
|
Packit |
4a16fb |
#include <stdlib.h>
|
|
Packit |
4a16fb |
#include <stdint.h>
|
|
Packit |
4a16fb |
#include <stdarg.h>
|
|
Packit |
4a16fb |
#include <unistd.h>
|
|
Packit |
4a16fb |
#include <string.h>
|
|
Packit |
4a16fb |
#include <fcntl.h>
|
|
Packit |
4a16fb |
#include <signal.h>
|
|
Packit |
4a16fb |
#include <poll.h>
|
|
Packit |
4a16fb |
#include <stdbool.h>
|
|
Packit |
4a16fb |
#include "control_local.h"
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get identifier of CTL handle
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \return ascii identifier of CTL handle
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* Returns the ASCII identifier of given CTL handle. It's the same
|
|
Packit |
4a16fb |
* identifier specified in snd_ctl_open().
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_name(snd_ctl_t *ctl)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl);
|
|
Packit |
4a16fb |
return ctl->name;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get type of CTL handle
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \return type of CTL handle
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* Returns the type #snd_ctl_type_t of given CTL handle.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
snd_ctl_type_t snd_ctl_type(snd_ctl_t *ctl)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl);
|
|
Packit |
4a16fb |
return ctl->type;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief close CTL handle
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* Closes the specified CTL handle and frees all associated
|
|
Packit |
4a16fb |
* resources.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_close(snd_ctl_t *ctl)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
while (!list_empty(&ctl->async_handlers)) {
|
|
Packit |
4a16fb |
snd_async_handler_t *h = list_entry(&ctl->async_handlers.next, snd_async_handler_t, hlist);
|
|
Packit |
4a16fb |
snd_async_del_handler(h);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
err = ctl->ops->close(ctl);
|
|
Packit |
4a16fb |
free(ctl->name);
|
|
Packit |
4a16fb |
snd_dlobj_cache_put(ctl->open_func);
|
|
Packit |
4a16fb |
free(ctl);
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief set nonblock mode
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param nonblock 0 = block, 1 = nonblock mode, 2 = abort
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
assert(ctl);
|
|
Packit |
4a16fb |
err = ctl->ops->nonblock(ctl, nonblock);
|
|
Packit |
4a16fb |
if (err < 0)
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
ctl->nonblock = nonblock;
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
#ifndef DOC_HIDDEN
|
|
Packit |
4a16fb |
int snd_ctl_new(snd_ctl_t **ctlp, snd_ctl_type_t type, const char *name)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
snd_ctl_t *ctl;
|
|
Packit |
4a16fb |
ctl = calloc(1, sizeof(*ctl));
|
|
Packit |
4a16fb |
if (!ctl)
|
|
Packit |
4a16fb |
return -ENOMEM;
|
|
Packit |
4a16fb |
ctl->type = type;
|
|
Packit |
4a16fb |
if (name)
|
|
Packit |
4a16fb |
ctl->name = strdup(name);
|
|
Packit |
4a16fb |
INIT_LIST_HEAD(&ctl->async_handlers);
|
|
Packit |
4a16fb |
*ctlp = ctl;
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief set async mode
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param sig Signal to raise: < 0 disable, 0 default (SIGIO)
|
|
Packit |
4a16fb |
* \param pid Process ID to signal: 0 current
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* A signal is raised when a change happens.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_async(snd_ctl_t *ctl, int sig, pid_t pid)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl);
|
|
Packit |
4a16fb |
if (sig == 0)
|
|
Packit |
4a16fb |
sig = SIGIO;
|
|
Packit |
4a16fb |
if (pid == 0)
|
|
Packit |
4a16fb |
pid = getpid();
|
|
Packit |
4a16fb |
return ctl->ops->async(ctl, sig, pid);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
#endif
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get count of poll descriptors for CTL handle
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \return count of poll descriptors
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_poll_descriptors_count(snd_ctl_t *ctl)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl);
|
|
Packit |
4a16fb |
if (ctl->ops->poll_descriptors_count)
|
|
Packit |
4a16fb |
return ctl->ops->poll_descriptors_count(ctl);
|
|
Packit |
4a16fb |
if (ctl->poll_fd < 0)
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
return 1;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get poll descriptors
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param pfds array of poll descriptors
|
|
Packit |
4a16fb |
* \param space space in the poll descriptor array
|
|
Packit |
4a16fb |
* \return count of filled descriptors
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_poll_descriptors(snd_ctl_t *ctl, struct pollfd *pfds, unsigned int space)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && pfds);
|
|
Packit |
4a16fb |
if (ctl->ops->poll_descriptors)
|
|
Packit |
4a16fb |
return ctl->ops->poll_descriptors(ctl, pfds, space);
|
|
Packit |
4a16fb |
if (ctl->poll_fd < 0)
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
if (space > 0) {
|
|
Packit |
4a16fb |
pfds->fd = ctl->poll_fd;
|
|
Packit |
4a16fb |
pfds->events = POLLIN|POLLERR|POLLNVAL;
|
|
Packit |
4a16fb |
return 1;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get returned events from poll descriptors
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param pfds array of poll descriptors
|
|
Packit |
4a16fb |
* \param nfds count of poll descriptors
|
|
Packit |
4a16fb |
* \param revents returned events
|
|
Packit |
4a16fb |
* \return zero if success, otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_poll_descriptors_revents(snd_ctl_t *ctl, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && pfds && revents);
|
|
Packit |
4a16fb |
if (ctl->ops->poll_revents)
|
|
Packit |
4a16fb |
return ctl->ops->poll_revents(ctl, pfds, nfds, revents);
|
|
Packit |
4a16fb |
if (nfds == 1) {
|
|
Packit |
4a16fb |
*revents = pfds->revents;
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Ask to be informed about events (poll, #snd_async_add_ctl_handler, #snd_ctl_read)
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param subscribe 0 = unsubscribe, 1 = subscribe, -1 = check subscribe or not
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_subscribe_events(snd_ctl_t *ctl, int subscribe)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl);
|
|
Packit |
4a16fb |
return ctl->ops->subscribe_events(ctl, subscribe);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get card related information
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param info Card info pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && info);
|
|
Packit |
4a16fb |
return ctl->ops->card_info(ctl, info);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get a list of element identifiers
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param list CTL element identifiers list pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t *list)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && list);
|
|
Packit |
4a16fb |
assert(list->space == 0 || list->pids);
|
|
Packit |
4a16fb |
return ctl->ops->element_list(ctl, list);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get CTL element information
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param info CTL element id/information pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && info && (info->id.name[0] || info->id.numid));
|
|
Packit |
4a16fb |
return ctl->ops->element_info(ctl, info);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit Service |
f36a15 |
#if 0 /* deprecated */
|
|
Packit |
4a16fb |
static bool validate_element_member_dimension(snd_ctl_elem_info_t *info)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
unsigned int members;
|
|
Packit |
4a16fb |
unsigned int i;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (info->dimen.d[0] == 0)
|
|
Packit |
4a16fb |
return true;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
members = 1;
|
|
Packit |
4a16fb |
for (i = 0; i < ARRAY_SIZE(info->dimen.d); ++i) {
|
|
Packit |
4a16fb |
if (info->dimen.d[i] == 0)
|
|
Packit |
4a16fb |
break;
|
|
Packit |
4a16fb |
members *= info->dimen.d[i];
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (members > info->count)
|
|
Packit |
4a16fb |
return false;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
for (++i; i < ARRAY_SIZE(info->dimen.d); ++i) {
|
|
Packit |
4a16fb |
if (info->dimen.d[i] > 0)
|
|
Packit |
4a16fb |
return false;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
return members == info->count;
|
|
Packit |
4a16fb |
}
|
|
Packit Service |
f36a15 |
#else /* deprecated */
|
|
Packit Service |
f36a15 |
#define validate_element_member_dimension(info) true
|
|
Packit Service |
f36a15 |
#endif /* deprecated */
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Create and add some user-defined control elements of integer type.
|
|
Packit |
4a16fb |
* \param ctl A handle of backend module for control interface.
|
|
Packit |
4a16fb |
* \param info Common iformation for a new element set, with ID of the first new
|
|
Packit |
4a16fb |
* element.
|
|
Packit |
4a16fb |
* \param element_count The number of elements added by this operation.
|
|
Packit |
4a16fb |
* \param member_count The number of members which a element has to
|
|
Packit |
4a16fb |
* represent its states.
|
|
Packit |
4a16fb |
* \param min Minimum value for each member of the elements.
|
|
Packit |
4a16fb |
* \param max Maximum value for each member of the elements.
|
|
Packit |
4a16fb |
* \param step The step of value for each member in the elements.
|
|
Packit |
4a16fb |
* \return Zero on success, otherwise a negative error code.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This function creates some user elements with integer type. These elements
|
|
Packit |
4a16fb |
* are not controlled by device drivers in kernel. They can be operated by the
|
|
Packit |
4a16fb |
* same way as usual elements added by the device drivers.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* The name field of \a id must be set with unique value to identify new control
|
|
Packit |
4a16fb |
* elements. After returning, all fields of \a id are filled. A element can be
|
|
Packit |
4a16fb |
* identified by the combination of name and index, or by numid.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* All of members in the new elements are locked. The value of each member is
|
|
Packit |
4a16fb |
* initialized with the minimum value.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Errors:
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* -EBUSY
|
|
Packit |
4a16fb |
* A element with ID \a id already exists.
|
|
Packit |
4a16fb |
* -EINVAL
|
|
Packit |
4a16fb |
* Some arguments include invalid value; i.e. ID field in \a info has no
|
|
Packit |
4a16fb |
* name, or the number of members is not between 1 to 127.
|
|
Packit |
4a16fb |
* -ENOMEM
|
|
Packit |
4a16fb |
* Out of memory, or there are too many user elements.
|
|
Packit |
4a16fb |
* -ENXIO
|
|
Packit |
4a16fb |
* This backend module does not support user elements of integer type.
|
|
Packit |
4a16fb |
* -ENODEV
|
|
Packit |
4a16fb |
* Device unplugged.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Compatibility:
|
|
Packit |
4a16fb |
* This function is added in version 1.1.2.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_add_integer_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
|
Packit |
4a16fb |
unsigned int element_count,
|
|
Packit |
4a16fb |
unsigned int member_count,
|
|
Packit |
4a16fb |
long min, long max, long step)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
snd_ctl_elem_value_t data = {0};
|
|
Packit |
4a16fb |
unsigned int i;
|
|
Packit |
4a16fb |
unsigned int j;
|
|
Packit |
4a16fb |
unsigned int numid;
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
info->type = SND_CTL_ELEM_TYPE_INTEGER;
|
|
Packit |
4a16fb |
info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
|
Packit |
4a16fb |
SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
|
|
Packit |
4a16fb |
SNDRV_CTL_ELEM_ACCESS_USER;
|
|
Packit |
4a16fb |
info->owner = element_count;
|
|
Packit |
4a16fb |
info->count = member_count;
|
|
Packit |
4a16fb |
info->value.integer.min = min;
|
|
Packit |
4a16fb |
info->value.integer.max = max;
|
|
Packit |
4a16fb |
info->value.integer.step = step;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (!validate_element_member_dimension(info))
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
err = ctl->ops->element_add(ctl, info);
|
|
Packit |
4a16fb |
if (err < 0)
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
numid = snd_ctl_elem_id_get_numid(&info->id);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/* Set initial value to all of members in all of added elements. */
|
|
Packit |
4a16fb |
data.id = info->id;
|
|
Packit |
4a16fb |
for (i = 0; i < element_count; i++) {
|
|
Packit |
4a16fb |
snd_ctl_elem_id_set_numid(&data.id, numid + i);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
for (j = 0; j < member_count; j++)
|
|
Packit |
4a16fb |
data.value.integer.value[j] = min;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
err = ctl->ops->element_write(ctl, &data);
|
|
Packit |
4a16fb |
if (err < 0)
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Create and add some user-defined control elements of integer64 type.
|
|
Packit |
4a16fb |
* \param ctl A handle of backend module for control interface.
|
|
Packit |
4a16fb |
* \param info Common iformation for a new element set, with ID of the first new
|
|
Packit |
4a16fb |
* element.
|
|
Packit |
4a16fb |
* \param element_count The number of elements added by this operation.
|
|
Packit |
4a16fb |
* \param member_count The number of members which a element has to
|
|
Packit |
4a16fb |
* represent its states.
|
|
Packit |
4a16fb |
* \param min Minimum value for each member of the elements.
|
|
Packit |
4a16fb |
* \param max Maximum value for each member of the elements.
|
|
Packit |
4a16fb |
* \param step The step of value for each member in the elements.
|
|
Packit |
4a16fb |
* \return Zero on success, otherwise a negative error code.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This function creates some user elements with integer64 type. These elements
|
|
Packit |
4a16fb |
* are not controlled by device drivers in kernel. They can be operated by the
|
|
Packit |
4a16fb |
* same way as usual elements added by the device drivers.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* The name field of \a id must be set with unique value to identify new control
|
|
Packit |
4a16fb |
* elements. After returning, all fields of \a id are filled. A element can be
|
|
Packit |
4a16fb |
* identified by the combination of name and index, or by numid.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* All of members in the new elements are locked. The value of each member is
|
|
Packit |
4a16fb |
* initialized with the minimum value.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Errors:
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* -EBUSY
|
|
Packit |
4a16fb |
* A element with ID \a id already exists.
|
|
Packit |
4a16fb |
* -EINVAL
|
|
Packit |
4a16fb |
* Some arguments include invalid value; i.e. ID has no name, or the number
|
|
Packit |
4a16fb |
* of members is not between 1 to 127.
|
|
Packit |
4a16fb |
* -ENOMEM
|
|
Packit |
4a16fb |
* Out of memory, or there are too many user elements.
|
|
Packit |
4a16fb |
* -ENXIO
|
|
Packit |
4a16fb |
* This backend module does not support user elements of integer64 type.
|
|
Packit |
4a16fb |
* -ENODEV
|
|
Packit |
4a16fb |
* Device unplugged.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Compatibility:
|
|
Packit |
4a16fb |
* This function is added in version 1.1.2.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_add_integer64_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
|
Packit |
4a16fb |
unsigned int element_count,
|
|
Packit |
4a16fb |
unsigned int member_count,
|
|
Packit |
4a16fb |
long long min, long long max, long long step)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
snd_ctl_elem_value_t data = {0};
|
|
Packit |
4a16fb |
unsigned int i;
|
|
Packit |
4a16fb |
unsigned int j;
|
|
Packit |
4a16fb |
unsigned int numid;
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
info->type = SND_CTL_ELEM_TYPE_INTEGER64;
|
|
Packit |
4a16fb |
info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
|
Packit |
4a16fb |
SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
|
|
Packit |
4a16fb |
SNDRV_CTL_ELEM_ACCESS_USER;
|
|
Packit |
4a16fb |
info->owner = element_count;
|
|
Packit |
4a16fb |
info->count = member_count;
|
|
Packit |
4a16fb |
info->value.integer64.min = min;
|
|
Packit |
4a16fb |
info->value.integer64.max = max;
|
|
Packit |
4a16fb |
info->value.integer64.step = step;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (!validate_element_member_dimension(info))
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
err = ctl->ops->element_add(ctl, info);
|
|
Packit |
4a16fb |
if (err < 0)
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
numid = snd_ctl_elem_id_get_numid(&info->id);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/* Set initial value to all of members in all of added elements. */
|
|
Packit |
4a16fb |
data.id = info->id;
|
|
Packit |
4a16fb |
for (i = 0; i < element_count; i++) {
|
|
Packit |
4a16fb |
snd_ctl_elem_id_set_numid(&data.id, numid + i);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
for (j = 0; j < member_count; j++)
|
|
Packit |
4a16fb |
data.value.integer64.value[j] = min;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
err = ctl->ops->element_write(ctl, &data);
|
|
Packit |
4a16fb |
if (err < 0)
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Create and add some user-defined control elements of boolean type.
|
|
Packit |
4a16fb |
* \param ctl A handle of backend module for control interface.
|
|
Packit |
4a16fb |
* \param info Common iformation for a new element set, with ID of the first new
|
|
Packit |
4a16fb |
* element.
|
|
Packit |
4a16fb |
* \param element_count The number of elements added by this operation.
|
|
Packit |
4a16fb |
* \param member_count The number of members which a element has to
|
|
Packit |
4a16fb |
* represent its states.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This function creates some user elements with boolean type. These elements
|
|
Packit |
4a16fb |
* are not controlled by device drivers in kernel. They can be operated by the
|
|
Packit |
4a16fb |
* same way as usual elements added by the device drivers.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* The name field of \a id must be set with unique value to identify new control
|
|
Packit |
4a16fb |
* elements. After returning, all fields of \a id are filled. A element can be
|
|
Packit |
4a16fb |
* identified by the combination of name and index, or by numid.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* All of members in the new elements are locked. The value of each member is
|
|
Packit |
4a16fb |
* initialized with false.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Errors:
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* -EBUSY
|
|
Packit |
4a16fb |
* A element with ID \a id already exists.
|
|
Packit |
4a16fb |
* -EINVAL
|
|
Packit |
4a16fb |
* Some parameters include invalid value; i.e. ID has no name, or the number
|
|
Packit |
4a16fb |
* of members is not between 1 to 127.
|
|
Packit |
4a16fb |
* -ENOMEM
|
|
Packit |
4a16fb |
* Out of memory, or there are too many user elements.
|
|
Packit |
4a16fb |
* -ENXIO
|
|
Packit |
4a16fb |
* This backend module does not support user elements of boolean type.
|
|
Packit |
4a16fb |
* -ENODEV
|
|
Packit |
4a16fb |
* Device unplugged.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Compatibility:
|
|
Packit |
4a16fb |
* This function is added in version 1.1.2.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_add_boolean_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
|
Packit |
4a16fb |
unsigned int element_count,
|
|
Packit |
4a16fb |
unsigned int member_count)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
info->type = SND_CTL_ELEM_TYPE_BOOLEAN;
|
|
Packit |
4a16fb |
info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
|
Packit |
4a16fb |
SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
|
|
Packit |
4a16fb |
SNDRV_CTL_ELEM_ACCESS_USER;
|
|
Packit |
4a16fb |
info->owner = element_count;
|
|
Packit |
4a16fb |
info->count = member_count;
|
|
Packit |
4a16fb |
info->value.integer.min = 0;
|
|
Packit |
4a16fb |
info->value.integer.max = 1;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (!validate_element_member_dimension(info))
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
return ctl->ops->element_add(ctl, info);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Create and add some user-defined control elements of enumerated type.
|
|
Packit |
4a16fb |
* \param ctl A handle of backend module for control interface.
|
|
Packit |
4a16fb |
* \param info Common iformation for a new element set, with ID of the first new
|
|
Packit |
4a16fb |
* element.
|
|
Packit |
4a16fb |
* \param element_count The number of elements added by this operation.
|
|
Packit |
4a16fb |
* \param member_count The number of members which a element has to
|
|
Packit |
4a16fb |
* represent its states.
|
|
Packit |
4a16fb |
* \param items Range of possible values (0 ... \a items - 1).
|
|
Packit |
4a16fb |
* \param labels An array containing \a items strings.
|
|
Packit |
4a16fb |
* \return Zero on success, otherwise a negative error code.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This function creates some user elements with enumerated type. These elements
|
|
Packit |
4a16fb |
* are not controlled by device drivers in kernel. They can be operated by the
|
|
Packit |
4a16fb |
* same way as usual elements added by the device drivers.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* The name field of \a id must be set with unique value to identify new control
|
|
Packit |
4a16fb |
* elements. After returning, all fields of \a id are filled. A element can be
|
|
Packit |
4a16fb |
* identified by the combination of name and index, or by numid.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* All of members in the new elements are locked. The value of each member is
|
|
Packit |
4a16fb |
* initialized with the first entry of labels.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Errors:
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* -EBUSY
|
|
Packit |
4a16fb |
* A control element with ID \a id already exists.
|
|
Packit |
4a16fb |
* -EINVAL
|
|
Packit |
4a16fb |
* Some arguments include invalid value; i.e. \a element_count is not
|
|
Packit |
4a16fb |
* between 1 to 127, or \a items is not at least one, or a string in \a
|
|
Packit |
4a16fb |
* labels is empty, or longer than 63 bytes, or total length of the labels
|
|
Packit |
4a16fb |
* requires more than 64 KiB storage.
|
|
Packit |
4a16fb |
* -ENOMEM
|
|
Packit |
4a16fb |
* Out of memory, or there are too many user control elements.
|
|
Packit |
4a16fb |
* -ENXIO
|
|
Packit |
4a16fb |
* This driver does not support (enumerated) user controls.
|
|
Packit |
4a16fb |
* -ENODEV
|
|
Packit |
4a16fb |
* Device unplugged.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Compatibility:
|
|
Packit |
4a16fb |
* This function is added in version 1.1.2.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_add_enumerated_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
|
Packit |
4a16fb |
unsigned int element_count,
|
|
Packit |
4a16fb |
unsigned int member_count,
|
|
Packit |
4a16fb |
unsigned int items,
|
|
Packit |
4a16fb |
const char *const labels[])
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
unsigned int i, bytes;
|
|
Packit |
4a16fb |
char *buf, *p;
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (ctl == NULL || info == NULL || info->id.name[0] == '\0' ||
|
|
Packit |
4a16fb |
labels == NULL)
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
info->type = SND_CTL_ELEM_TYPE_ENUMERATED;
|
|
Packit |
4a16fb |
info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
|
Packit |
4a16fb |
SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
|
|
Packit |
4a16fb |
SNDRV_CTL_ELEM_ACCESS_USER;
|
|
Packit |
4a16fb |
info->owner = element_count;
|
|
Packit |
4a16fb |
info->count = member_count;
|
|
Packit |
4a16fb |
info->value.enumerated.items = items;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
bytes = 0;
|
|
Packit |
4a16fb |
for (i = 0; i < items; ++i)
|
|
Packit |
4a16fb |
bytes += strlen(labels[i]) + 1;
|
|
Packit |
4a16fb |
if (bytes == 0)
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
buf = malloc(bytes);
|
|
Packit |
4a16fb |
if (buf == NULL)
|
|
Packit |
4a16fb |
return -ENOMEM;
|
|
Packit |
4a16fb |
info->value.enumerated.names_ptr = (uintptr_t)buf;
|
|
Packit |
4a16fb |
info->value.enumerated.names_length = bytes;
|
|
Packit |
4a16fb |
p = buf;
|
|
Packit |
4a16fb |
for (i = 0; i < items; ++i) {
|
|
Packit |
4a16fb |
strcpy(p, labels[i]);
|
|
Packit |
4a16fb |
p += strlen(labels[i]) + 1;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (!validate_element_member_dimension(info))
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
err = ctl->ops->element_add(ctl, info);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
free(buf);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Create and add some user-defined control elements of bytes type.
|
|
Packit |
4a16fb |
* \param ctl A handle of backend module for control interface.
|
|
Packit |
4a16fb |
* \param info Common iformation for a new element set, with ID of the first new
|
|
Packit |
4a16fb |
* element.
|
|
Packit |
4a16fb |
* \param element_count The number of elements added by this operation.
|
|
Packit |
4a16fb |
* \param member_count The number of members which a element has to
|
|
Packit |
4a16fb |
* represent its states.
|
|
Packit |
4a16fb |
* \return Zero on success, otherwise a negative error code.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This function creates some user elements with bytes type. These elements are
|
|
Packit |
4a16fb |
* not controlled by device drivers in kernel. They can be operated by the same
|
|
Packit |
4a16fb |
* way as usual elements added by the device drivers.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* The name field of \a id must be set with unique value to identify new control
|
|
Packit |
4a16fb |
* elements. After returning, all fields of \a id are filled. A element can be
|
|
Packit |
4a16fb |
* identified by the combination of name and index, or by numid.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* All of members in the new elements are locked. The value of each member is
|
|
Packit |
4a16fb |
* initialized with the minimum value.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Errors:
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* -EBUSY
|
|
Packit |
4a16fb |
* A element with ID \a id already exists.
|
|
Packit |
4a16fb |
* -EINVAL
|
|
Packit |
4a16fb |
* Some arguments include invalid value; i.e. ID has no name, or the number
|
|
Packit |
4a16fb |
* of members is not between 1 to 511.
|
|
Packit |
4a16fb |
* -ENOMEM
|
|
Packit |
4a16fb |
* Out of memory, or there are too many user elements.
|
|
Packit |
4a16fb |
* -ENXIO
|
|
Packit |
4a16fb |
* This backend module does not support user elements of bytes type.
|
|
Packit |
4a16fb |
* -ENODEV
|
|
Packit |
4a16fb |
* Device unplugged.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Compatibility:
|
|
Packit |
4a16fb |
* This function is added in version 1.1.2.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_add_bytes_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
|
|
Packit |
4a16fb |
unsigned int element_count,
|
|
Packit |
4a16fb |
unsigned int member_count)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
if (ctl == NULL || info == NULL || info->id.name[0] == '\0')
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
info->type = SND_CTL_ELEM_TYPE_BYTES;
|
|
Packit |
4a16fb |
info->access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
|
Packit |
4a16fb |
SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
|
|
Packit |
4a16fb |
SNDRV_CTL_ELEM_ACCESS_USER;
|
|
Packit |
4a16fb |
info->owner = element_count;
|
|
Packit |
4a16fb |
info->count = member_count;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (!validate_element_member_dimension(info))
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
return ctl->ops->element_add(ctl, info);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Create and add an user-defined control element of integer type.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This is a wrapper function to snd_ctl_add_integer_elem_set() for a control
|
|
Packit |
4a16fb |
* element. This doesn't fill the id data with full information, thus it's
|
|
Packit |
4a16fb |
* recommended to use snd_ctl_add_integer_elem_set(), instead.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_add_integer(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
|
|
Packit |
4a16fb |
unsigned int member_count,
|
|
Packit |
4a16fb |
long min, long max, long step)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
snd_ctl_elem_info_t info = {0};
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
assert(ctl && id && id->name[0]);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
info.id = *id;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
return snd_ctl_add_integer_elem_set(ctl, &info, 1, member_count,
|
|
Packit |
4a16fb |
min, max, step);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Create and add an user-defined control element of integer64 type.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This is a wrapper function to snd_ctl_add_integer64_elem_set() for a single
|
|
Packit |
4a16fb |
* control element. This doesn't fill the id data with full information, thus
|
|
Packit |
4a16fb |
* it's recommended to use snd_ctl_add_integer64_elem_set(), instead.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_add_integer64(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
|
|
Packit |
4a16fb |
unsigned int member_count,
|
|
Packit |
4a16fb |
long long min, long long max, long long step)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
snd_ctl_elem_info_t info = {0};
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
assert(ctl && id && id->name[0]);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
info.id = *id;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
return snd_ctl_add_integer64_elem_set(ctl, &info, 1, member_count,
|
|
Packit |
4a16fb |
min, max, step);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Create and add an user-defined control element of boolean type.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This is a wrapper function to snd_ctl_add_boolean_elem_set() for a single
|
|
Packit |
4a16fb |
* control element. This doesn't fill the id data with full information, thus
|
|
Packit |
4a16fb |
* it's recommended to use snd_ctl_add_boolean_elem_set(), instead.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_add_boolean(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
|
|
Packit |
4a16fb |
unsigned int member_count)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
snd_ctl_elem_info_t info = {0};
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
assert(ctl && id && id->name[0]);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
info.id = *id;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
return snd_ctl_add_boolean_elem_set(ctl, &info, 1, member_count);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Create and add a user-defined control element of enumerated type.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This is a wrapper function to snd_ctl_add_enumerated_elem_set() for a single
|
|
Packit |
4a16fb |
* control element. This doesn't fill the id data with full information, thus
|
|
Packit |
4a16fb |
* it's recommended to use snd_ctl_add_enumerated_elem_set(), instead.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This function is added in version 1.0.25.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_add_enumerated(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
|
|
Packit |
4a16fb |
unsigned int member_count, unsigned int items,
|
|
Packit |
4a16fb |
const char *const labels[])
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
snd_ctl_elem_info_t info = {0};
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
assert(ctl && id && id->name[0] && labels);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
info.id = *id;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
return snd_ctl_add_enumerated_elem_set(ctl, &info, 1, member_count,
|
|
Packit |
4a16fb |
items, labels);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Create and add a user-defined control element of IEC958 type.
|
|
Packit |
4a16fb |
* \param[in] ctl A handle of backend module for control interface.
|
|
Packit |
4a16fb |
* \param[in,out] id ID of the new control element.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* This function creates an user element with IEC958 type. This element is not
|
|
Packit |
4a16fb |
* controlled by device drivers in kernel. It can be operated by the same way as
|
|
Packit |
4a16fb |
* usual elements added by the device drivers.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* The name field of \a id must be set with unique value to identify a new
|
|
Packit |
4a16fb |
* control element. After returning, all fields of \a id are filled. A element
|
|
Packit |
4a16fb |
* can be identified by the combination of name and index, or by numid.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* A member in the new element is locked and filled with zero.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Errors:
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* -EBUSY
|
|
Packit |
4a16fb |
* A control element with ID \a id already exists.
|
|
Packit |
4a16fb |
* -EINVAL
|
|
Packit |
4a16fb |
* ID has no name.
|
|
Packit |
4a16fb |
* -ENOMEM
|
|
Packit |
4a16fb |
* Out of memory, or there are too many user elements.
|
|
Packit |
4a16fb |
* -ENXIO
|
|
Packit |
4a16fb |
* This backend module does not support user elements of IEC958 type.
|
|
Packit |
4a16fb |
* -ENODEV
|
|
Packit |
4a16fb |
* Device unplugged.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_add_iec958(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
snd_ctl_elem_info_t info = {0};
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
assert(ctl && id && id->name[0]);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
info.id = *id;
|
|
Packit |
4a16fb |
info.type = SND_CTL_ELEM_TYPE_IEC958;
|
|
Packit |
4a16fb |
info.owner = 1;
|
|
Packit |
4a16fb |
info.count = 1;
|
|
Packit |
4a16fb |
return ctl->ops->element_add(ctl, &info;;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Remove an user CTL element
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param id CTL element identification
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_remove(snd_ctl_t *ctl, snd_ctl_elem_id_t *id)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && id && (id->name[0] || id->numid));
|
|
Packit |
4a16fb |
return ctl->ops->element_remove(ctl, id);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get CTL element value
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param data Data of an element.
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_read(snd_ctl_t *ctl, snd_ctl_elem_value_t *data)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && data && (data->id.name[0] || data->id.numid));
|
|
Packit |
4a16fb |
return ctl->ops->element_read(ctl, data);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set CTL element value
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param data Data of an element.
|
|
Packit |
4a16fb |
* \retval 0 on success
|
|
Packit |
4a16fb |
* \retval >0 on success when value was changed
|
|
Packit |
4a16fb |
* \retval <0 a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *data)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && data && (data->id.name[0] || data->id.numid));
|
|
Packit |
4a16fb |
return ctl->ops->element_write(ctl, data);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
static int snd_ctl_tlv_do(snd_ctl_t *ctl, int op_flag,
|
|
Packit |
4a16fb |
const snd_ctl_elem_id_t *id,
|
|
Packit |
4a16fb |
unsigned int *tlv, unsigned int tlv_size)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
snd_ctl_elem_info_t *info = NULL;
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (id->numid == 0) {
|
|
Packit |
4a16fb |
info = calloc(1, sizeof(*info));
|
|
Packit |
4a16fb |
if (info == NULL)
|
|
Packit |
4a16fb |
return -ENOMEM;
|
|
Packit |
4a16fb |
info->id = *id;
|
|
Packit |
4a16fb |
id = &info->id;
|
|
Packit |
4a16fb |
err = snd_ctl_elem_info(ctl, info);
|
|
Packit |
4a16fb |
if (err < 0)
|
|
Packit |
4a16fb |
goto __err;
|
|
Packit |
4a16fb |
if (id->numid == 0) {
|
|
Packit |
4a16fb |
err = -ENOENT;
|
|
Packit |
4a16fb |
goto __err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
err = ctl->ops->element_tlv(ctl, op_flag, id->numid, tlv, tlv_size);
|
|
Packit |
4a16fb |
__err:
|
|
Packit |
4a16fb |
if (info)
|
|
Packit |
4a16fb |
free(info);
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Read structured data from an element set to given buffer.
|
|
Packit |
4a16fb |
* \param ctl A handle of backend module for control interface.
|
|
Packit |
4a16fb |
* \param id ID of an element.
|
|
Packit |
4a16fb |
* \param tlv An array with members of unsigned int type.
|
|
Packit |
4a16fb |
* \param tlv_size The length of the array.
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* The format of an array of \a tlv argument is:
|
|
Packit |
4a16fb |
* tlv[0]: Type. One of SND_CTL_TLVT_XXX.
|
|
Packit |
4a16fb |
* tlv[1]: Length. The length of value in units of byte.
|
|
Packit |
4a16fb |
* tlv[2..]: Value. Depending on the type.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* Details are described in <sound/tlv.h>.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_tlv_read(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
|
|
Packit |
4a16fb |
unsigned int *tlv, unsigned int tlv_size)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
assert(ctl && id && (id->name[0] || id->numid) && tlv);
|
|
Packit |
4a16fb |
if (tlv_size < 2 * sizeof(int))
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
/* 1.0.12 driver doesn't return the error even if the user TLV
|
|
Packit |
4a16fb |
* is empty. So, initialize TLV here with an invalid type
|
|
Packit |
4a16fb |
* and compare the returned value after ioctl for checking
|
|
Packit |
4a16fb |
* the validity of TLV.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
tlv[SNDRV_CTL_TLVO_TYPE] = -1;
|
|
Packit |
4a16fb |
tlv[SNDRV_CTL_TLVO_LEN] = 0;
|
|
Packit |
4a16fb |
err = snd_ctl_tlv_do(ctl, 0, id, tlv, tlv_size);
|
|
Packit |
4a16fb |
if (err >= 0 && tlv[SNDRV_CTL_TLVO_TYPE] == (unsigned int)-1)
|
|
Packit |
4a16fb |
err = -ENXIO;
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Write structured data from given buffer to an element set.
|
|
Packit |
4a16fb |
* \param ctl A handle of backend module for control interface.
|
|
Packit |
4a16fb |
* \param id ID of an element.
|
|
Packit |
4a16fb |
* \param tlv An array with members of unsigned int type. The second member
|
|
Packit |
4a16fb |
* must represent total bytes of the rest of array.
|
|
Packit |
4a16fb |
* \retval 0 on success
|
|
Packit |
4a16fb |
* \retval >0 on success when value was changed
|
|
Packit |
4a16fb |
* \retval <0 a negative error code
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* The format of an array of \a tlv argument is:
|
|
Packit |
4a16fb |
* tlv[0]: Type. One of SND_CTL_TLVT_XXX.
|
|
Packit |
4a16fb |
* tlv[1]: Length. The length of value in units of byte.
|
|
Packit |
4a16fb |
* tlv[2..]: Value. Depending on the type.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* Details are described in <sound/tlv.h>.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_tlv_write(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
|
|
Packit |
4a16fb |
const unsigned int *tlv)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && id && (id->name[0] || id->numid) && tlv);
|
|
Packit |
4a16fb |
return snd_ctl_tlv_do(ctl, 1, id, (unsigned int *)tlv,
|
|
Packit |
4a16fb |
tlv[SNDRV_CTL_TLVO_LEN] + 2 * sizeof(unsigned int));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Process structured data from given buffer for an element set.
|
|
Packit |
4a16fb |
* \param ctl A handle of backend module for control interface.
|
|
Packit |
4a16fb |
* \param id ID of an element.
|
|
Packit |
4a16fb |
* \param tlv An array with members of unsigned int type. The second member
|
|
Packit |
4a16fb |
* must represent total bytes of the rest of array.
|
|
Packit |
4a16fb |
* \retval 0 on success
|
|
Packit |
4a16fb |
* \retval >0 on success when value was changed
|
|
Packit |
4a16fb |
* \retval <0 a negative error code
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* The format of an array of \a tlv argument is:
|
|
Packit |
4a16fb |
* tlv[0]: Type. One of SND_CTL_TLVT_XXX.
|
|
Packit |
4a16fb |
* tlv[1]: Length. The length of value in units of byte.
|
|
Packit |
4a16fb |
* tlv[2..]: Value. Depending on the type.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* Details are described in <sound/tlv.h>.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_tlv_command(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
|
|
Packit |
4a16fb |
const unsigned int *tlv)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && id && (id->name[0] || id->numid) && tlv);
|
|
Packit |
4a16fb |
return snd_ctl_tlv_do(ctl, -1, id, (unsigned int *)tlv,
|
|
Packit |
4a16fb |
tlv[SNDRV_CTL_TLVO_LEN] + 2 * sizeof(unsigned int));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Lock CTL element
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param id CTL element id pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_lock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && id);
|
|
Packit |
4a16fb |
return ctl->ops->element_lock(ctl, id);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Unlock CTL element
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param id CTL element id pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_unlock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && id);
|
|
Packit |
4a16fb |
return ctl->ops->element_unlock(ctl, id);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get next hardware dependent device number
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param device current device on entry and next device on return
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_hwdep_next_device(snd_ctl_t *ctl, int *device)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && device);
|
|
Packit |
4a16fb |
return ctl->ops->hwdep_next_device(ctl, device);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info about a hardware dependent device
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param info Hardware dependent device id/info pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_hwdep_info(snd_ctl_t *ctl, snd_hwdep_info_t * info)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && info);
|
|
Packit |
4a16fb |
return ctl->ops->hwdep_info(ctl, info);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get next PCM device number
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param device current device on entry and next device on return
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_pcm_next_device(snd_ctl_t *ctl, int * device)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && device);
|
|
Packit |
4a16fb |
return ctl->ops->pcm_next_device(ctl, device);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info about a PCM device
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param info PCM device id/info pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_pcm_info(snd_ctl_t *ctl, snd_pcm_info_t * info)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && info);
|
|
Packit |
4a16fb |
return ctl->ops->pcm_info(ctl, info);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set preferred PCM subdevice number of successive PCM open
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param subdev Preferred PCM subdevice number
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_pcm_prefer_subdevice(snd_ctl_t *ctl, int subdev)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl);
|
|
Packit |
4a16fb |
return ctl->ops->pcm_prefer_subdevice(ctl, subdev);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get next RawMidi device number
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param device current device on entry and next device on return
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_rawmidi_next_device(snd_ctl_t *ctl, int * device)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && device);
|
|
Packit |
4a16fb |
return ctl->ops->rawmidi_next_device(ctl, device);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info about a RawMidi device
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param info RawMidi device id/info pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && info);
|
|
Packit |
4a16fb |
return ctl->ops->rawmidi_info(ctl, info);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set preferred RawMidi subdevice number of successive RawMidi open
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param subdev Preferred RawMidi subdevice number
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl);
|
|
Packit |
4a16fb |
return ctl->ops->rawmidi_prefer_subdevice(ctl, subdev);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set Power State to given SND_CTL_POWER_* value and do the power management
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param state Desired Power State
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_set_power_state(snd_ctl_t *ctl, unsigned int state)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl);
|
|
Packit |
4a16fb |
if (ctl->ops->set_power_state)
|
|
Packit |
4a16fb |
return ctl->ops->set_power_state(ctl, state);
|
|
Packit |
4a16fb |
return -ENXIO;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get actual Power State
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param state Destination value
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_get_power_state(snd_ctl_t *ctl, unsigned int *state)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl);
|
|
Packit |
4a16fb |
if (ctl->ops->get_power_state)
|
|
Packit |
4a16fb |
return ctl->ops->get_power_state(ctl, state);
|
|
Packit |
4a16fb |
return -ENXIO;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Read an event
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param event Event pointer
|
|
Packit |
4a16fb |
* \return number of events read otherwise a negative error code on failure
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_read(snd_ctl_t *ctl, snd_ctl_event_t *event)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl && event);
|
|
Packit |
4a16fb |
return (ctl->ops->read)(ctl, event);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Wait for a CTL to become ready (i.e. at least one event pending)
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param timeout maximum time in milliseconds to wait
|
|
Packit |
4a16fb |
* \return 0 otherwise a negative error code on failure
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
struct pollfd *pfd;
|
|
Packit |
4a16fb |
unsigned short revents;
|
|
Packit |
4a16fb |
int npfds, err, err_poll;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
npfds = snd_ctl_poll_descriptors_count(ctl);
|
|
Packit |
4a16fb |
if (npfds <= 0 || npfds >= 16) {
|
|
Packit |
4a16fb |
SNDERR("Invalid poll_fds %d\n", npfds);
|
|
Packit |
4a16fb |
return -EIO;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
pfd = alloca(sizeof(*pfd) * npfds);
|
|
Packit |
4a16fb |
err = snd_ctl_poll_descriptors(ctl, pfd, npfds);
|
|
Packit |
4a16fb |
if (err < 0)
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
if (err != npfds) {
|
|
Packit |
4a16fb |
SNDMSG("invalid poll descriptors %d\n", err);
|
|
Packit |
4a16fb |
return -EIO;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
for (;;) {
|
|
Packit |
4a16fb |
err_poll = poll(pfd, npfds, timeout);
|
|
Packit |
4a16fb |
if (err_poll < 0)
|
|
Packit |
4a16fb |
return -errno;
|
|
Packit |
4a16fb |
if (! err_poll)
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
err = snd_ctl_poll_descriptors_revents(ctl, pfd, npfds, &revents);
|
|
Packit |
4a16fb |
if (err < 0)
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
if (revents & (POLLERR | POLLNVAL))
|
|
Packit |
4a16fb |
return -EIO;
|
|
Packit |
4a16fb |
if (revents & (POLLIN | POLLOUT))
|
|
Packit |
4a16fb |
return 1;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Add an async handler for a CTL
|
|
Packit |
4a16fb |
* \param handler Returned handler handle
|
|
Packit |
4a16fb |
* \param ctl CTL handle
|
|
Packit |
4a16fb |
* \param callback Callback function
|
|
Packit |
4a16fb |
* \param private_data Callback private data
|
|
Packit |
4a16fb |
* \return 0 otherwise a negative error code on failure
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_async_add_ctl_handler(snd_async_handler_t **handler, snd_ctl_t *ctl,
|
|
Packit |
4a16fb |
snd_async_callback_t callback, void *private_data)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
int was_empty;
|
|
Packit |
4a16fb |
snd_async_handler_t *h;
|
|
Packit |
4a16fb |
err = snd_async_add_handler(&h, _snd_ctl_async_descriptor(ctl),
|
|
Packit |
4a16fb |
callback, private_data);
|
|
Packit |
4a16fb |
if (err < 0)
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
h->type = SND_ASYNC_HANDLER_CTL;
|
|
Packit |
4a16fb |
h->u.ctl = ctl;
|
|
Packit |
4a16fb |
was_empty = list_empty(&ctl->async_handlers);
|
|
Packit |
4a16fb |
list_add_tail(&h->hlist, &ctl->async_handlers);
|
|
Packit |
4a16fb |
if (was_empty) {
|
|
Packit |
4a16fb |
err = snd_ctl_async(ctl, snd_async_handler_get_signo(h), getpid());
|
|
Packit |
4a16fb |
if (err < 0) {
|
|
Packit |
4a16fb |
snd_async_del_handler(h);
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
*handler = h;
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Return CTL handle related to an async handler
|
|
Packit |
4a16fb |
* \param handler Async handler handle
|
|
Packit |
4a16fb |
* \return CTL handle
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
snd_ctl_t *snd_async_handler_get_ctl(snd_async_handler_t *handler)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(handler->type == SND_ASYNC_HANDLER_CTL);
|
|
Packit |
4a16fb |
return handler->u.ctl;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
static const char *const build_in_ctls[] = {
|
|
Packit |
4a16fb |
"hw", "shm", NULL
|
|
Packit |
4a16fb |
};
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
|
|
Packit |
4a16fb |
snd_config_t *ctl_root, snd_config_t *ctl_conf, int mode)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
const char *str;
|
|
Packit |
4a16fb |
char *buf = NULL, *buf1 = NULL;
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
snd_config_t *conf, *type_conf = NULL;
|
|
Packit |
4a16fb |
snd_config_iterator_t i, next;
|
|
Packit |
4a16fb |
const char *lib = NULL, *open_name = NULL;
|
|
Packit |
4a16fb |
const char *id;
|
|
Packit |
4a16fb |
int (*open_func)(snd_ctl_t **, const char *, snd_config_t *, snd_config_t *, int) = NULL;
|
|
Packit |
4a16fb |
#ifndef PIC
|
|
Packit |
4a16fb |
extern void *snd_control_open_symbols(void);
|
|
Packit |
4a16fb |
#endif
|
|
Packit |
4a16fb |
if (snd_config_get_type(ctl_conf) != SND_CONFIG_TYPE_COMPOUND) {
|
|
Packit |
4a16fb |
if (name)
|
|
Packit |
4a16fb |
SNDERR("Invalid type for CTL %s definition", name);
|
|
Packit |
4a16fb |
else
|
|
Packit |
4a16fb |
SNDERR("Invalid type for CTL definition");
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
err = snd_config_search(ctl_conf, "type", &conf;;
|
|
Packit |
4a16fb |
if (err < 0) {
|
|
Packit |
4a16fb |
SNDERR("type is not defined");
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
err = snd_config_get_id(conf, &id;;
|
|
Packit |
4a16fb |
if (err < 0) {
|
|
Packit |
4a16fb |
SNDERR("unable to get id");
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
err = snd_config_get_string(conf, &str);
|
|
Packit |
4a16fb |
if (err < 0) {
|
|
Packit |
4a16fb |
SNDERR("Invalid type for %s", id);
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
err = snd_config_search_definition(ctl_root, "ctl_type", str, &type_conf);
|
|
Packit |
4a16fb |
if (err >= 0) {
|
|
Packit |
4a16fb |
if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
|
|
Packit |
4a16fb |
SNDERR("Invalid type for CTL type %s definition", str);
|
|
Packit |
4a16fb |
err = -EINVAL;
|
|
Packit |
4a16fb |
goto _err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
snd_config_for_each(i, next, type_conf) {
|
|
Packit |
4a16fb |
snd_config_t *n = snd_config_iterator_entry(i);
|
|
Packit |
4a16fb |
const char *id;
|
|
Packit |
4a16fb |
if (snd_config_get_id(n, &id) < 0)
|
|
Packit |
4a16fb |
continue;
|
|
Packit |
4a16fb |
if (strcmp(id, "comment") == 0)
|
|
Packit |
4a16fb |
continue;
|
|
Packit |
4a16fb |
if (strcmp(id, "lib") == 0) {
|
|
Packit |
4a16fb |
err = snd_config_get_string(n, &lib);
|
|
Packit |
4a16fb |
if (err < 0) {
|
|
Packit |
4a16fb |
SNDERR("Invalid type for %s", id);
|
|
Packit |
4a16fb |
goto _err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
continue;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
if (strcmp(id, "open") == 0) {
|
|
Packit |
4a16fb |
err = snd_config_get_string(n, &open_name);
|
|
Packit |
4a16fb |
if (err < 0) {
|
|
Packit |
4a16fb |
SNDERR("Invalid type for %s", id);
|
|
Packit |
4a16fb |
goto _err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
continue;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
SNDERR("Unknown field %s", id);
|
|
Packit |
4a16fb |
err = -EINVAL;
|
|
Packit |
4a16fb |
goto _err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
if (!open_name) {
|
|
Packit |
4a16fb |
buf = malloc(strlen(str) + 32);
|
|
Packit |
4a16fb |
if (buf == NULL) {
|
|
Packit |
4a16fb |
err = -ENOMEM;
|
|
Packit |
4a16fb |
goto _err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
open_name = buf;
|
|
Packit |
4a16fb |
sprintf(buf, "_snd_ctl_%s_open", str);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
if (!lib) {
|
|
Packit |
4a16fb |
const char *const *build_in = build_in_ctls;
|
|
Packit |
4a16fb |
while (*build_in) {
|
|
Packit |
4a16fb |
if (!strcmp(*build_in, str))
|
|
Packit |
4a16fb |
break;
|
|
Packit |
4a16fb |
build_in++;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
if (*build_in == NULL) {
|
|
Packit Service |
f36a15 |
buf1 = malloc(strlen(str) + 32);
|
|
Packit |
4a16fb |
if (buf1 == NULL) {
|
|
Packit |
4a16fb |
err = -ENOMEM;
|
|
Packit |
4a16fb |
goto _err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
lib = buf1;
|
|
Packit Service |
f36a15 |
sprintf(buf1, "libasound_module_ctl_%s.so", str);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
#ifndef PIC
|
|
Packit |
4a16fb |
snd_control_open_symbols();
|
|
Packit |
4a16fb |
#endif
|
|
Packit |
4a16fb |
open_func = snd_dlobj_cache_get(lib, open_name,
|
|
Packit |
4a16fb |
SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 1);
|
|
Packit |
4a16fb |
if (open_func) {
|
|
Packit |
4a16fb |
err = open_func(ctlp, name, ctl_root, ctl_conf, mode);
|
|
Packit |
4a16fb |
if (err >= 0) {
|
|
Packit |
4a16fb |
(*ctlp)->open_func = open_func;
|
|
Packit |
4a16fb |
err = 0;
|
|
Packit |
4a16fb |
} else {
|
|
Packit |
4a16fb |
snd_dlobj_cache_put(open_func);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
} else {
|
|
Packit |
4a16fb |
err = -ENXIO;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
_err:
|
|
Packit |
4a16fb |
if (type_conf)
|
|
Packit |
4a16fb |
snd_config_delete(type_conf);
|
|
Packit |
4a16fb |
free(buf);
|
|
Packit |
4a16fb |
free(buf1);
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
static int snd_ctl_open_noupdate(snd_ctl_t **ctlp, snd_config_t *root, const char *name, int mode)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
snd_config_t *ctl_conf;
|
|
Packit |
4a16fb |
err = snd_config_search_definition(root, "ctl", name, &ctl_conf);
|
|
Packit |
4a16fb |
if (err < 0) {
|
|
Packit |
4a16fb |
SNDERR("Invalid CTL %s", name);
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
err = snd_ctl_open_conf(ctlp, name, root, ctl_conf, mode);
|
|
Packit |
4a16fb |
snd_config_delete(ctl_conf);
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Opens a CTL
|
|
Packit |
4a16fb |
* \param ctlp Returned CTL handle
|
|
Packit |
4a16fb |
* \param name ASCII identifier of the CTL handle
|
|
Packit |
4a16fb |
* \param mode Open mode (see #SND_CTL_NONBLOCK, #SND_CTL_ASYNC)
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_open(snd_ctl_t **ctlp, const char *name, int mode)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
snd_config_t *top;
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
assert(ctlp && name);
|
|
Packit |
4a16fb |
err = snd_config_update_ref(&top);
|
|
Packit |
4a16fb |
if (err < 0)
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
err = snd_ctl_open_noupdate(ctlp, top, name, mode);
|
|
Packit |
4a16fb |
snd_config_unref(top);
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Opens a CTL using local configuration
|
|
Packit |
4a16fb |
* \param ctlp Returned CTL handle
|
|
Packit |
4a16fb |
* \param name ASCII identifier of the CTL handle
|
|
Packit |
4a16fb |
* \param mode Open mode (see #SND_CTL_NONBLOCK, #SND_CTL_ASYNC)
|
|
Packit |
4a16fb |
* \param lconf Local configuration
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_open_lconf(snd_ctl_t **ctlp, const char *name,
|
|
Packit |
4a16fb |
int mode, snd_config_t *lconf)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctlp && name && lconf);
|
|
Packit |
4a16fb |
return snd_ctl_open_noupdate(ctlp, lconf, name, mode);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Opens a fallback CTL
|
|
Packit |
4a16fb |
* \param ctlp Returned CTL handle
|
|
Packit |
4a16fb |
* \param root Configuration root
|
|
Packit |
4a16fb |
* \param name ASCII identifier of the CTL handle used as fallback
|
|
Packit |
4a16fb |
* \param orig_name The original ASCII name
|
|
Packit |
4a16fb |
* \param mode Open mode (see #SND_CTL_NONBLOCK, #SND_CTL_ASYNC)
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_open_fallback(snd_ctl_t **ctlp, snd_config_t *root,
|
|
Packit |
4a16fb |
const char *name, const char *orig_name, int mode)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
int err;
|
|
Packit |
4a16fb |
assert(ctlp && name && root);
|
|
Packit |
4a16fb |
err = snd_ctl_open_noupdate(ctlp, root, name, mode);
|
|
Packit |
4a16fb |
if (err >= 0) {
|
|
Packit |
4a16fb |
free((*ctlp)->name);
|
|
Packit |
4a16fb |
(*ctlp)->name = orig_name ? strdup(orig_name) : NULL;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
return err;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
#ifndef DOC_HIDDEN
|
|
Packit |
4a16fb |
#define TYPE(v) [SND_CTL_ELEM_TYPE_##v] = #v
|
|
Packit |
4a16fb |
#define IFACE(v) [SND_CTL_ELEM_IFACE_##v] = #v
|
|
Packit |
4a16fb |
#define IFACE1(v, n) [SND_CTL_ELEM_IFACE_##v] = #n
|
|
Packit |
4a16fb |
#define EVENT(v) [SND_CTL_EVENT_##v] = #v
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
static const char *const snd_ctl_elem_type_names[] = {
|
|
Packit |
4a16fb |
TYPE(NONE),
|
|
Packit |
4a16fb |
TYPE(BOOLEAN),
|
|
Packit |
4a16fb |
TYPE(INTEGER),
|
|
Packit |
4a16fb |
TYPE(ENUMERATED),
|
|
Packit |
4a16fb |
TYPE(BYTES),
|
|
Packit |
4a16fb |
TYPE(IEC958),
|
|
Packit |
4a16fb |
TYPE(INTEGER64),
|
|
Packit |
4a16fb |
};
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
static const char *const snd_ctl_elem_iface_names[] = {
|
|
Packit |
4a16fb |
IFACE(CARD),
|
|
Packit |
4a16fb |
IFACE(HWDEP),
|
|
Packit |
4a16fb |
IFACE(MIXER),
|
|
Packit |
4a16fb |
IFACE(PCM),
|
|
Packit |
4a16fb |
IFACE(RAWMIDI),
|
|
Packit |
4a16fb |
IFACE(TIMER),
|
|
Packit |
4a16fb |
IFACE(SEQUENCER),
|
|
Packit |
4a16fb |
};
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
static const char *const snd_ctl_event_type_names[] = {
|
|
Packit |
4a16fb |
EVENT(ELEM),
|
|
Packit |
4a16fb |
};
|
|
Packit |
4a16fb |
#endif
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get name of a CTL element type
|
|
Packit |
4a16fb |
* \param type CTL element type
|
|
Packit |
4a16fb |
* \return ascii name of CTL element type
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_elem_type_name(snd_ctl_elem_type_t type)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(type <= SND_CTL_ELEM_TYPE_LAST);
|
|
Packit |
4a16fb |
return snd_ctl_elem_type_names[type];
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get name of a CTL element related interface
|
|
Packit |
4a16fb |
* \param iface CTL element related interface
|
|
Packit |
4a16fb |
* \return ascii name of CTL element related interface
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_elem_iface_name(snd_ctl_elem_iface_t iface)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(iface <= SND_CTL_ELEM_IFACE_LAST);
|
|
Packit |
4a16fb |
return snd_ctl_elem_iface_names[iface];
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get name of a CTL event type
|
|
Packit |
4a16fb |
* \param type CTL event type
|
|
Packit |
4a16fb |
* \return ascii name of CTL event type
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_event_type_name(snd_ctl_event_type_t type)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(type <= SND_CTL_EVENT_LAST);
|
|
Packit |
4a16fb |
return snd_ctl_event_type_names[type];
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief allocate space for CTL element identifiers list
|
|
Packit |
4a16fb |
* \param obj CTL element identifiers list
|
|
Packit |
4a16fb |
* \param entries Entries to allocate
|
|
Packit |
4a16fb |
* \return 0 on success otherwise a negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_list_alloc_space(snd_ctl_elem_list_t *obj, unsigned int entries)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
free(obj->pids);
|
|
Packit |
4a16fb |
obj->pids = calloc(entries, sizeof(*obj->pids));
|
|
Packit |
4a16fb |
if (!obj->pids) {
|
|
Packit |
4a16fb |
obj->space = 0;
|
|
Packit |
4a16fb |
return -ENOMEM;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
obj->space = entries;
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief free previously allocated space for CTL element identifiers list
|
|
Packit |
4a16fb |
* \param obj CTL element identifiers list
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_list_free_space(snd_ctl_elem_list_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
free(obj->pids);
|
|
Packit |
4a16fb |
obj->pids = NULL;
|
|
Packit |
4a16fb |
obj->space = 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get event mask for an element related event
|
|
Packit |
4a16fb |
* \param obj CTL event
|
|
Packit |
4a16fb |
* \return event mask for element related event
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_event_elem_get_mask(const snd_ctl_event_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_EVENT_ELEM);
|
|
Packit |
4a16fb |
return obj->data.elem.mask;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get CTL element identifier for an element related event
|
|
Packit |
4a16fb |
* \param obj CTL event
|
|
Packit |
4a16fb |
* \param ptr Pointer to returned CTL element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_event_elem_get_id(const snd_ctl_event_t *obj, snd_ctl_elem_id_t *ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj && ptr);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_EVENT_ELEM);
|
|
Packit |
4a16fb |
*ptr = obj->data.elem.id;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get element numeric identifier for an element related event
|
|
Packit |
4a16fb |
* \param obj CTL event
|
|
Packit |
4a16fb |
* \return element numeric identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_event_elem_get_numid(const snd_ctl_event_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_EVENT_ELEM);
|
|
Packit |
4a16fb |
return obj->data.elem.id.numid;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get interface part of CTL element identifier for an element related event
|
|
Packit |
4a16fb |
* \param obj CTL event
|
|
Packit |
4a16fb |
* \return interface part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
snd_ctl_elem_iface_t snd_ctl_event_elem_get_interface(const snd_ctl_event_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_EVENT_ELEM);
|
|
Packit |
4a16fb |
return obj->data.elem.id.iface;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get device part of CTL element identifier for an element related event
|
|
Packit |
4a16fb |
* \param obj CTL event
|
|
Packit |
4a16fb |
* \return device part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_event_elem_get_device(const snd_ctl_event_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_EVENT_ELEM);
|
|
Packit |
4a16fb |
return obj->data.elem.id.device;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get subdevice part of CTL element identifier for an element related event
|
|
Packit |
4a16fb |
* \param obj CTL event
|
|
Packit |
4a16fb |
* \return subdevice part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_event_elem_get_subdevice(const snd_ctl_event_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_EVENT_ELEM);
|
|
Packit |
4a16fb |
return obj->data.elem.id.subdevice;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get name part of CTL element identifier for an element related event
|
|
Packit |
4a16fb |
* \param obj CTL event
|
|
Packit |
4a16fb |
* \return name part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_event_elem_get_name(const snd_ctl_event_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_EVENT_ELEM);
|
|
Packit |
4a16fb |
return (const char *)obj->data.elem.id.name;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get index part of CTL element identifier for an element related event
|
|
Packit |
4a16fb |
* \param obj CTL event
|
|
Packit |
4a16fb |
* \return index part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_event_elem_get_index(const snd_ctl_event_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_EVENT_ELEM);
|
|
Packit |
4a16fb |
return obj->data.elem.id.index;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
#ifndef DOC_HIDDEN
|
|
Packit |
4a16fb |
int _snd_ctl_poll_descriptor(snd_ctl_t *ctl)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ctl);
|
|
Packit |
4a16fb |
return ctl->poll_fd;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
#endif
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get size of #snd_ctl_elem_id_t
|
|
Packit |
4a16fb |
* \return size in bytes
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
size_t snd_ctl_elem_id_sizeof()
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
return sizeof(snd_ctl_elem_id_t);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief allocate an invalid #snd_ctl_elem_id_t using standard malloc
|
|
Packit |
4a16fb |
* \param ptr returned pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_id_malloc(snd_ctl_elem_id_t **ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ptr);
|
|
Packit |
4a16fb |
*ptr = calloc(1, sizeof(snd_ctl_elem_id_t));
|
|
Packit |
4a16fb |
if (!*ptr)
|
|
Packit |
4a16fb |
return -ENOMEM;
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief frees a previously allocated #snd_ctl_elem_id_t
|
|
Packit |
4a16fb |
* \param obj pointer to object to free
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_id_free(snd_ctl_elem_id_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
free(obj);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief clear given #snd_ctl_elem_id_t object
|
|
Packit |
4a16fb |
* \param obj pointer to object to clear
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_id_clear(snd_ctl_elem_id_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
memset(obj, 0, sizeof(snd_ctl_elem_id_t));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief copy one #snd_ctl_elem_id_t to another
|
|
Packit |
4a16fb |
* \param dst pointer to destination
|
|
Packit |
4a16fb |
* \param src pointer to source
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_id_copy(snd_ctl_elem_id_t *dst, const snd_ctl_elem_id_t *src)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(dst && src);
|
|
Packit |
4a16fb |
*dst = *src;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get numeric identifier from a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \return CTL element numeric identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_id_get_numid(const snd_ctl_elem_id_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->numid;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get interface part of a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \return CTL element related interface
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
snd_ctl_elem_iface_t snd_ctl_elem_id_get_interface(const snd_ctl_elem_id_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->iface;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get device part of a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \return CTL element related device
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_id_get_device(const snd_ctl_elem_id_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->device;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get subdevice part of a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \return CTL element related subdevice
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_id_get_subdevice(const snd_ctl_elem_id_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->subdevice;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get name part of a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \return CTL element name
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_elem_id_get_name(const snd_ctl_elem_id_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return (const char *)obj->name;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get index part of a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \return CTL element index
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_id_get_index(const snd_ctl_elem_id_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->index;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set numeric identifier for a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \param val CTL element numeric identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_id_set_numid(snd_ctl_elem_id_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->numid = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set interface part for a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \param val CTL element related interface
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_id_set_interface(snd_ctl_elem_id_t *obj, snd_ctl_elem_iface_t val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->iface = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set device part for a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \param val CTL element related device
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_id_set_device(snd_ctl_elem_id_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->device = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set subdevice part for a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \param val CTL element related subdevice
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_id_set_subdevice(snd_ctl_elem_id_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->subdevice = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set name part for a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \param val CTL element name
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_id_set_name(snd_ctl_elem_id_t *obj, const char *val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
snd_strlcpy((char *)obj->name, val, sizeof(obj->name));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set index part for a CTL element identifier
|
|
Packit |
4a16fb |
* \param obj CTL element identifier
|
|
Packit |
4a16fb |
* \param val CTL element index
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_id_set_index(snd_ctl_elem_id_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->index = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get size of #snd_ctl_card_info_t
|
|
Packit |
4a16fb |
* \return size in bytes
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
size_t snd_ctl_card_info_sizeof()
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
return sizeof(snd_ctl_card_info_t);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief allocate an invalid #snd_ctl_card_info_t using standard malloc
|
|
Packit |
4a16fb |
* \param ptr returned pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_card_info_malloc(snd_ctl_card_info_t **ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ptr);
|
|
Packit |
4a16fb |
*ptr = calloc(1, sizeof(snd_ctl_card_info_t));
|
|
Packit |
4a16fb |
if (!*ptr)
|
|
Packit |
4a16fb |
return -ENOMEM;
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief frees a previously allocated #snd_ctl_card_info_t
|
|
Packit |
4a16fb |
* \param obj pointer to object to free
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_card_info_free(snd_ctl_card_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
free(obj);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief clear given #snd_ctl_card_info_t object
|
|
Packit |
4a16fb |
* \param obj pointer to object to clear
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_card_info_clear(snd_ctl_card_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
memset(obj, 0, sizeof(snd_ctl_card_info_t));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief copy one #snd_ctl_card_info_t to another
|
|
Packit |
4a16fb |
* \param dst pointer to destination
|
|
Packit |
4a16fb |
* \param src pointer to source
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_card_info_copy(snd_ctl_card_info_t *dst, const snd_ctl_card_info_t *src)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(dst && src);
|
|
Packit |
4a16fb |
*dst = *src;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get card number from a CTL card info
|
|
Packit |
4a16fb |
* \param obj CTL card info
|
|
Packit |
4a16fb |
* \return card number
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_card_info_get_card(const snd_ctl_card_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->card;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get card identifier from a CTL card info
|
|
Packit |
4a16fb |
* \param obj CTL card info
|
|
Packit |
4a16fb |
* \return card identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_card_info_get_id(const snd_ctl_card_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return (const char *)obj->id;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get card driver name from a CTL card info
|
|
Packit |
4a16fb |
* \param obj CTL card info
|
|
Packit |
4a16fb |
* \return card driver name
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_card_info_get_driver(const snd_ctl_card_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return (const char *)obj->driver;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get card name from a CTL card info
|
|
Packit |
4a16fb |
* \param obj CTL card info
|
|
Packit |
4a16fb |
* \return card name
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_card_info_get_name(const snd_ctl_card_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return (const char *)obj->name;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get card long name from a CTL card info
|
|
Packit |
4a16fb |
* \param obj CTL card info
|
|
Packit |
4a16fb |
* \return card long name
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_card_info_get_longname(const snd_ctl_card_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return (const char *)obj->longname;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get card mixer name from a CTL card info
|
|
Packit |
4a16fb |
* \param obj CTL card info
|
|
Packit |
4a16fb |
* \return card mixer name
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_card_info_get_mixername(const snd_ctl_card_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return (const char *)obj->mixername;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get card component list from a CTL card info
|
|
Packit |
4a16fb |
* \param obj CTL card info
|
|
Packit |
4a16fb |
* \return card mixer identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_card_info_get_components(const snd_ctl_card_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return (const char *)obj->components;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get size of #snd_ctl_event_t
|
|
Packit |
4a16fb |
* \return size in bytes
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
size_t snd_ctl_event_sizeof()
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
return sizeof(snd_ctl_event_t);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief allocate an invalid #snd_ctl_event_t using standard malloc
|
|
Packit |
4a16fb |
* \param ptr returned pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_event_malloc(snd_ctl_event_t **ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ptr);
|
|
Packit |
4a16fb |
*ptr = calloc(1, sizeof(snd_ctl_event_t));
|
|
Packit |
4a16fb |
if (!*ptr)
|
|
Packit |
4a16fb |
return -ENOMEM;
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief frees a previously allocated #snd_ctl_event_t
|
|
Packit |
4a16fb |
* \param obj pointer to object to free
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_event_free(snd_ctl_event_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
free(obj);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief clear given #snd_ctl_event_t object
|
|
Packit |
4a16fb |
* \param obj pointer to object to clear
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_event_clear(snd_ctl_event_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
memset(obj, 0, sizeof(snd_ctl_event_t));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief copy one #snd_ctl_event_t to another
|
|
Packit |
4a16fb |
* \param dst pointer to destination
|
|
Packit |
4a16fb |
* \param src pointer to source
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_event_copy(snd_ctl_event_t *dst, const snd_ctl_event_t *src)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(dst && src);
|
|
Packit |
4a16fb |
*dst = *src;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get type of a CTL event
|
|
Packit |
4a16fb |
* \param obj CTL event
|
|
Packit |
4a16fb |
* \return CTL event type
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
snd_ctl_event_type_t snd_ctl_event_get_type(const snd_ctl_event_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->type;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get size of #snd_ctl_elem_list_t
|
|
Packit |
4a16fb |
* \return size in bytes
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
size_t snd_ctl_elem_list_sizeof()
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
return sizeof(snd_ctl_elem_list_t);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief allocate an invalid #snd_ctl_elem_list_t using standard malloc
|
|
Packit |
4a16fb |
* \param ptr returned pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_list_malloc(snd_ctl_elem_list_t **ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ptr);
|
|
Packit |
4a16fb |
*ptr = calloc(1, sizeof(snd_ctl_elem_list_t));
|
|
Packit |
4a16fb |
if (!*ptr)
|
|
Packit |
4a16fb |
return -ENOMEM;
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief frees a previously allocated #snd_ctl_elem_list_t
|
|
Packit |
4a16fb |
* \param obj pointer to object to free
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_list_free(snd_ctl_elem_list_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
free(obj);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief clear given #snd_ctl_elem_list_t object
|
|
Packit |
4a16fb |
* \param obj pointer to object to clear
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_list_clear(snd_ctl_elem_list_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
memset(obj, 0, sizeof(snd_ctl_elem_list_t));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief copy one #snd_ctl_elem_list_t to another
|
|
Packit |
4a16fb |
* \param dst pointer to destination
|
|
Packit |
4a16fb |
* \param src pointer to source
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_list_copy(snd_ctl_elem_list_t *dst, const snd_ctl_elem_list_t *src)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(dst && src);
|
|
Packit |
4a16fb |
*dst = *src;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set index of first wanted CTL element identifier in a CTL element identifiers list
|
|
Packit |
4a16fb |
* \param obj CTL element identifiers list
|
|
Packit |
4a16fb |
* \param val index of CTL element to put at position 0 of list
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_list_set_offset(snd_ctl_elem_list_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->offset = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get number of used entries in CTL element identifiers list
|
|
Packit |
4a16fb |
* \param obj CTL element identifier list
|
|
Packit |
4a16fb |
* \return number of used entries
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_list_get_used(const snd_ctl_elem_list_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->used;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get total count of elements present in CTL device (information present in every filled CTL element identifiers list)
|
|
Packit |
4a16fb |
* \param obj CTL element identifier list
|
|
Packit |
4a16fb |
* \return total number of elements
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_list_get_count(const snd_ctl_elem_list_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->count;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get CTL element identifier for an entry of a CTL element identifiers list
|
|
Packit |
4a16fb |
* \param obj CTL element identifier list
|
|
Packit |
4a16fb |
* \param idx Index of entry
|
|
Packit |
4a16fb |
* \param ptr Pointer to returned CTL element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_list_get_id(const snd_ctl_elem_list_t *obj, unsigned int idx, snd_ctl_elem_id_t *ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj && ptr);
|
|
Packit |
4a16fb |
assert(idx < obj->used);
|
|
Packit |
4a16fb |
*ptr = obj->pids[idx];
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get CTL element numeric identifier for an entry of a CTL element identifiers list
|
|
Packit |
4a16fb |
* \param obj CTL element identifier list
|
|
Packit |
4a16fb |
* \param idx Index of entry
|
|
Packit |
4a16fb |
* \return CTL element numeric identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_list_get_numid(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < obj->used);
|
|
Packit |
4a16fb |
return obj->pids[idx].numid;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get interface part of CTL element identifier for an entry of a CTL element identifiers list
|
|
Packit |
4a16fb |
* \param obj CTL element identifier list
|
|
Packit |
4a16fb |
* \param idx Index of entry
|
|
Packit |
4a16fb |
* \return CTL element related interface
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
snd_ctl_elem_iface_t snd_ctl_elem_list_get_interface(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < obj->used);
|
|
Packit |
4a16fb |
return obj->pids[idx].iface;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get device part of CTL element identifier for an entry of a CTL element identifiers list
|
|
Packit |
4a16fb |
* \param obj CTL element identifier list
|
|
Packit |
4a16fb |
* \param idx Index of entry
|
|
Packit |
4a16fb |
* \return CTL element related device
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_list_get_device(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < obj->used);
|
|
Packit |
4a16fb |
return obj->pids[idx].device;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get subdevice part of CTL element identifier for an entry of a CTL element identifiers list
|
|
Packit |
4a16fb |
* \param obj CTL element identifier list
|
|
Packit |
4a16fb |
* \param idx Index of entry
|
|
Packit |
4a16fb |
* \return CTL element related subdevice
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_list_get_subdevice(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < obj->used);
|
|
Packit |
4a16fb |
return obj->pids[idx].subdevice;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get name part of CTL element identifier for an entry of a CTL element identifiers list
|
|
Packit |
4a16fb |
* \param obj CTL element identifier list
|
|
Packit |
4a16fb |
* \param idx Index of entry
|
|
Packit |
4a16fb |
* \return CTL element name
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_elem_list_get_name(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < obj->used);
|
|
Packit |
4a16fb |
return (const char *)obj->pids[idx].name;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get index part of CTL element identifier for an entry of a CTL element identifiers list
|
|
Packit |
4a16fb |
* \param obj CTL element identifier list
|
|
Packit |
4a16fb |
* \param idx Index of entry
|
|
Packit |
4a16fb |
* \return CTL element index
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_list_get_index(const snd_ctl_elem_list_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < obj->used);
|
|
Packit |
4a16fb |
return obj->pids[idx].index;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief get size of #snd_ctl_elem_info_t
|
|
Packit |
4a16fb |
* \return size in bytes
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
size_t snd_ctl_elem_info_sizeof()
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
return sizeof(snd_ctl_elem_info_t);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief allocate an invalid #snd_ctl_elem_info_t using standard malloc
|
|
Packit |
4a16fb |
* \param ptr returned pointer
|
|
Packit |
4a16fb |
* \return 0 on success otherwise negative error code
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_malloc(snd_ctl_elem_info_t **ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ptr);
|
|
Packit |
4a16fb |
*ptr = calloc(1, sizeof(snd_ctl_elem_info_t));
|
|
Packit |
4a16fb |
if (!*ptr)
|
|
Packit |
4a16fb |
return -ENOMEM;
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief frees a previously allocated #snd_ctl_elem_info_t
|
|
Packit |
4a16fb |
* \param obj pointer to object to free
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_free(snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
free(obj);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief clear given #snd_ctl_elem_info_t object
|
|
Packit |
4a16fb |
* \param obj pointer to object to clear
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_clear(snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
memset(obj, 0, sizeof(snd_ctl_elem_info_t));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief copy one #snd_ctl_elem_info_t to another
|
|
Packit |
4a16fb |
* \param dst pointer to destination
|
|
Packit |
4a16fb |
* \param src pointer to source
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_copy(snd_ctl_elem_info_t *dst, const snd_ctl_elem_info_t *src)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(dst && src);
|
|
Packit |
4a16fb |
*dst = *src;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get type from a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return CTL element content type
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
snd_ctl_elem_type_t snd_ctl_elem_info_get_type(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->type;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info about readability from a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return 0 if element is not readable, 1 if element is readable
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_is_readable(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_READ);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info about writability from a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return 0 if element is not writable, 1 if element is not writable
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_is_writable(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_WRITE);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info about notification feasibility from a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return 0 if all element value changes are notified to subscribed applications, 1 otherwise
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_is_volatile(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_VOLATILE);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info about status from a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return 0 if element value is not active, 1 if is active
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_is_inactive(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info whether an element is locked
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return 0 if element value is currently changeable, 1 if it's locked by another application
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_is_locked(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_LOCK);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info if I own an element
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return 0 if element value is currently changeable, 1 if it's locked by another application
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_is_owner(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_OWNER);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info if it's a user element
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return 0 if element value is a system element, 1 if it's a user-created element
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_is_user(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_USER);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info about TLV readability from a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return 0 if element's TLV is not readable, 1 if element's TLV is readable
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_is_tlv_readable(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info about TLV writeability from a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return 0 if element's TLV is not writable, 1 if element's TLV is writable
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_is_tlv_writable(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get info about TLV command possibility from a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return 0 if element's TLV command is not possible, 1 if element's TLV command is supported
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_is_tlv_commandable(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return !!(obj->access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief (DEPRECATED) Get info about values passing policy from a CTL element value
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return 0 if element value need to be passed by contents, 1 if need to be passed with a pointer
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_is_indirect(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
link_warning(snd_ctl_elem_info_is_indirect, "Warning: snd_ctl_elem_info_is_indirect is deprecated, do not use it");
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get owner of a locked element
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return value entries count
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
pid_t snd_ctl_elem_info_get_owner(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->owner;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get number of value entries from a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return value entries count
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_info_get_count(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->count;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get minimum value from a #SND_CTL_ELEM_TYPE_INTEGER CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return Minimum value
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
long snd_ctl_elem_info_get_min(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_ELEM_TYPE_INTEGER);
|
|
Packit |
4a16fb |
return obj->value.integer.min;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get maximum value from a #SND_CTL_ELEM_TYPE_INTEGER CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return Maximum value
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
long snd_ctl_elem_info_get_max(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_ELEM_TYPE_INTEGER);
|
|
Packit |
4a16fb |
return obj->value.integer.max;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get value step from a #SND_CTL_ELEM_TYPE_INTEGER CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return Step
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
long snd_ctl_elem_info_get_step(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_ELEM_TYPE_INTEGER);
|
|
Packit |
4a16fb |
return obj->value.integer.step;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get minimum value from a #SND_CTL_ELEM_TYPE_INTEGER64 CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return Minimum value
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
long long snd_ctl_elem_info_get_min64(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_ELEM_TYPE_INTEGER64);
|
|
Packit |
4a16fb |
return obj->value.integer64.min;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get maximum value from a #SND_CTL_ELEM_TYPE_INTEGER64 CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return Maximum value
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
long long snd_ctl_elem_info_get_max64(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_ELEM_TYPE_INTEGER64);
|
|
Packit |
4a16fb |
return obj->value.integer64.max;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get value step from a #SND_CTL_ELEM_TYPE_INTEGER64 CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return Step
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
long long snd_ctl_elem_info_get_step64(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_ELEM_TYPE_INTEGER64);
|
|
Packit |
4a16fb |
return obj->value.integer64.step;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get number of items available from a #SND_CTL_ELEM_TYPE_ENUMERATED CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return items count
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_info_get_items(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_ELEM_TYPE_ENUMERATED);
|
|
Packit |
4a16fb |
return obj->value.enumerated.items;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Select item in a #SND_CTL_ELEM_TYPE_ENUMERATED CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \param val item number
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_set_item(snd_ctl_elem_info_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->value.enumerated.item = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get name for selected item in a #SND_CTL_ELEM_TYPE_ENUMERATED CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return name of chosen item
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_elem_info_get_item_name(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(obj->type == SND_CTL_ELEM_TYPE_ENUMERATED);
|
|
Packit |
4a16fb |
return obj->value.enumerated.name;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get count of dimensions for given element
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return zero value if no dimensions are defined, otherwise positive value with count of dimensions
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \deprecated Since 1.1.5
|
|
Packit |
4a16fb |
* #snd_ctl_elem_info_get_dimensions is deprecated without any replacement.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
#ifndef DOXYGEN
|
|
Packit Service |
f36a15 |
EXPORT_SYMBOL int INTERNAL(snd_ctl_elem_info_get_dimensions)(const snd_ctl_elem_info_t *obj ATTRIBUTE_UNUSED)
|
|
Packit |
4a16fb |
#else
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_get_dimensions(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
#endif
|
|
Packit |
4a16fb |
{
|
|
Packit Service |
f36a15 |
#if 0 /* deprecated */
|
|
Packit |
4a16fb |
int i;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
for (i = 3; i >= 0; i--)
|
|
Packit |
4a16fb |
if (obj->dimen.d[i])
|
|
Packit |
4a16fb |
break;
|
|
Packit |
4a16fb |
return i + 1;
|
|
Packit Service |
f36a15 |
#else
|
|
Packit Service |
f36a15 |
return -EINVAL;
|
|
Packit Service |
f36a15 |
#endif
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
use_default_symbol_version(__snd_ctl_elem_info_get_dimensions, snd_ctl_elem_info_get_dimensions, ALSA_0.9.3);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get specified of dimension width for given element
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \param idx The dimension index
|
|
Packit |
4a16fb |
* \return zero value if no dimension width is defined, otherwise positive value with with of specified dimension
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \deprecated Since 1.1.5
|
|
Packit |
4a16fb |
* #snd_ctl_elem_info_get_dimension is deprecated without any replacement.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
#ifndef DOXYGEN
|
|
Packit Service |
f36a15 |
EXPORT_SYMBOL int INTERNAL(snd_ctl_elem_info_get_dimension)(const snd_ctl_elem_info_t *obj ATTRIBUTE_UNUSED, unsigned int idx ATTRIBUTE_UNUSED)
|
|
Packit |
4a16fb |
#else
|
|
Packit |
4a16fb |
int snd_ctl_elem_info_get_dimension(const snd_ctl_elem_info_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
#endif
|
|
Packit |
4a16fb |
{
|
|
Packit Service |
f36a15 |
#if 0 /* deprecated */
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
if (idx > 3)
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
return obj->dimen.d[idx];
|
|
Packit Service |
f36a15 |
#else /* deprecated */
|
|
Packit Service |
f36a15 |
return -EINVAL;
|
|
Packit Service |
f36a15 |
#endif /* deprecated */
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
use_default_symbol_version(__snd_ctl_elem_info_get_dimension, snd_ctl_elem_info_get_dimension, ALSA_0.9.3);
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set width to a specified dimension level of given element information.
|
|
Packit |
4a16fb |
* \param info Information of an element.
|
|
Packit |
4a16fb |
* \param dimension Dimension width for each level by member unit.
|
|
Packit |
4a16fb |
* \return Zero on success, otherwise a negative error code.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Errors:
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* -EINVAL
|
|
Packit |
4a16fb |
* Invalid arguments are given as parameters.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \par Compatibility:
|
|
Packit |
4a16fb |
* This function is added in version 1.1.2.
|
|
Packit |
4a16fb |
*
|
|
Packit |
4a16fb |
* \deprecated Since 1.1.5
|
|
Packit |
4a16fb |
* #snd_ctl_elem_info_set_dimension is deprecated without any replacement.
|
|
Packit |
4a16fb |
*/
|
|
Packit Service |
f36a15 |
int snd_ctl_elem_info_set_dimension(snd_ctl_elem_info_t *info ATTRIBUTE_UNUSED,
|
|
Packit Service |
f36a15 |
const int dimension[4] ATTRIBUTE_UNUSED)
|
|
Packit |
4a16fb |
{
|
|
Packit Service |
f36a15 |
#if 0 /* deprecated */
|
|
Packit |
4a16fb |
unsigned int i;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
if (info == NULL)
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
for (i = 0; i < ARRAY_SIZE(info->dimen.d); i++) {
|
|
Packit |
4a16fb |
if (dimension[i] < 0)
|
|
Packit |
4a16fb |
return -EINVAL;
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
info->dimen.d[i] = dimension[i];
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
return 0;
|
|
Packit Service |
f36a15 |
#else /* deprecated */
|
|
Packit Service |
f36a15 |
return -EINVAL;
|
|
Packit Service |
f36a15 |
#endif /* deprecated */
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \param ptr Pointer to returned CTL element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_get_id(const snd_ctl_elem_info_t *obj, snd_ctl_elem_id_t *ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj && ptr);
|
|
Packit |
4a16fb |
*ptr = obj->id;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get element numeric identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return element numeric identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_info_get_numid(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->id.numid;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get interface part of CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return interface part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
snd_ctl_elem_iface_t snd_ctl_elem_info_get_interface(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->id.iface;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get device part of CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return device part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_info_get_device(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->id.device;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get subdevice part of CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return subdevice part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_info_get_subdevice(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->id.subdevice;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get name part of CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return name part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_elem_info_get_name(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return (const char *)obj->id.name;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get index part of CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \return index part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_info_get_index(const snd_ctl_elem_info_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->id.index;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \param ptr CTL element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_set_id(snd_ctl_elem_info_t *obj, const snd_ctl_elem_id_t *ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj && ptr);
|
|
Packit |
4a16fb |
obj->id = *ptr;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set element numeric identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \param val element numeric identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_set_numid(snd_ctl_elem_info_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->id.numid = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set interface part of CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \param val interface part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_set_interface(snd_ctl_elem_info_t *obj, snd_ctl_elem_iface_t val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->id.iface = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set device part of CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \param val device part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_set_device(snd_ctl_elem_info_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->id.device = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set subdevice part of CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \param val subdevice part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_set_subdevice(snd_ctl_elem_info_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->id.subdevice = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set name part of CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \param val name part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_set_name(snd_ctl_elem_info_t *obj, const char *val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
snd_strlcpy((char *)obj->id.name, val, sizeof(obj->id.name));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set index part of CTL element identifier of a CTL element id/info
|
|
Packit |
4a16fb |
* \param obj CTL element id/info
|
|
Packit |
4a16fb |
* \param val index part of element identifier
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_info_set_index(snd_ctl_elem_info_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->id.index = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get size of data structure for an element.
|
|
Packit |
4a16fb |
* \return Size in bytes.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
size_t snd_ctl_elem_value_sizeof()
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
return sizeof(snd_ctl_elem_value_t);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Allocate an invalid #snd_ctl_elem_value_t using standard malloc(3).
|
|
Packit |
4a16fb |
* \param ptr Returned pointer for data of an element.
|
|
Packit |
4a16fb |
* \return 0 on success otherwise negative error code.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_value_malloc(snd_ctl_elem_value_t **ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(ptr);
|
|
Packit |
4a16fb |
*ptr = calloc(1, sizeof(snd_ctl_elem_value_t));
|
|
Packit |
4a16fb |
if (!*ptr)
|
|
Packit |
4a16fb |
return -ENOMEM;
|
|
Packit |
4a16fb |
return 0;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Frees a previously allocated data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_free(snd_ctl_elem_value_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
free(obj);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Clear given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_clear(snd_ctl_elem_value_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
memset(obj, 0, sizeof(snd_ctl_elem_value_t));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Copy two data of elements.
|
|
Packit |
4a16fb |
* \param dst Pointer to destination.
|
|
Packit |
4a16fb |
* \param src Pointer to source.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_copy(snd_ctl_elem_value_t *dst,
|
|
Packit |
4a16fb |
const snd_ctl_elem_value_t *src)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(dst && src);
|
|
Packit |
4a16fb |
*dst = *src;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Compare one data of an element to the other.
|
|
Packit |
4a16fb |
* \param left Pointer to first data.
|
|
Packit |
4a16fb |
* \param right Pointer to second data.
|
|
Packit |
4a16fb |
* \return 0 on match, less than or greater than otherwise, see memcmp(3).
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_value_compare(snd_ctl_elem_value_t *left,
|
|
Packit |
4a16fb |
const snd_ctl_elem_value_t *right)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(left && right);
|
|
Packit |
4a16fb |
return memcmp(left, right, sizeof(*left));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get element identifier from given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param ptr Pointer for element identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_get_id(const snd_ctl_elem_value_t *obj, snd_ctl_elem_id_t *ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj && ptr);
|
|
Packit |
4a16fb |
*ptr = obj->id;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get element numeric identifier from given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \return Element numeric identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_value_get_numid(const snd_ctl_elem_value_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->id.numid;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get interface part of element identifier from given data of an
|
|
Packit |
4a16fb |
* element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \return Interface part of element identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
snd_ctl_elem_iface_t snd_ctl_elem_value_get_interface(const snd_ctl_elem_value_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->id.iface;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get device part of element identifier from given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \return Device part of element identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_value_get_device(const snd_ctl_elem_value_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->id.device;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get subdevice part of element identifier from given data of an
|
|
Packit |
4a16fb |
* element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \return Subdevice part of element identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_value_get_subdevice(const snd_ctl_elem_value_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->id.subdevice;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get name part of element identifier from given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \return Name part of element identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const char *snd_ctl_elem_value_get_name(const snd_ctl_elem_value_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return (const char *)obj->id.name;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get index part of element identifier from given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \return Index part of element identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_value_get_index(const snd_ctl_elem_value_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->id.index;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set element identifier to given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param ptr Pointer to an element identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_id(snd_ctl_elem_value_t *obj, const snd_ctl_elem_id_t *ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj && ptr);
|
|
Packit |
4a16fb |
obj->id = *ptr;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set numeric identifier to given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param val Value for numeric identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_numid(snd_ctl_elem_value_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->id.numid = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set interface part of element identifier to given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param val Value for interface part of element identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_interface(snd_ctl_elem_value_t *obj, snd_ctl_elem_iface_t val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->id.iface = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set device part of element identifier to given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param val Value for device part of element identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_device(snd_ctl_elem_value_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->id.device = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set subdevice part of element identifier to given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param val Value for subdevice part of element identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_subdevice(snd_ctl_elem_value_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->id.subdevice = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set name part of element identifier to given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param val Value for name part of element identifier,
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_name(snd_ctl_elem_value_t *obj, const char *val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
snd_strlcpy((char *)obj->id.name, val, sizeof(obj->id.name));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set index part of element identifier to given data of an element.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param val Value for index part of element identifier.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_index(snd_ctl_elem_value_t *obj, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
obj->id.index = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get value of a specified member from given data as an element of
|
|
Packit |
4a16fb |
* boolean type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param idx Index of member in the element.
|
|
Packit |
4a16fb |
* \return Value for the member.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
int snd_ctl_elem_value_get_boolean(const snd_ctl_elem_value_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < ARRAY_SIZE(obj->value.integer.value));
|
|
Packit |
4a16fb |
return obj->value.integer.value[idx];
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get value of a specified member from given data as an element of
|
|
Packit |
4a16fb |
* integer type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param idx Index of member in the element.
|
|
Packit |
4a16fb |
* \return Value for the member.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
long snd_ctl_elem_value_get_integer(const snd_ctl_elem_value_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < ARRAY_SIZE(obj->value.integer.value));
|
|
Packit |
4a16fb |
return obj->value.integer.value[idx];
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get value of a specified member from given data as an element of
|
|
Packit |
4a16fb |
* integer64 type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param idx Index of member in the element.
|
|
Packit |
4a16fb |
* \return Value for the member.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
long long snd_ctl_elem_value_get_integer64(const snd_ctl_elem_value_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < ARRAY_SIZE(obj->value.integer64.value));
|
|
Packit |
4a16fb |
return obj->value.integer64.value[idx];
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get value of a specified member from given data as an element of
|
|
Packit |
4a16fb |
* enumerated type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param idx Index of member in the element.
|
|
Packit |
4a16fb |
* \return Value for the member. This is an index of name set in the element.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned int snd_ctl_elem_value_get_enumerated(const snd_ctl_elem_value_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < ARRAY_SIZE(obj->value.enumerated.item));
|
|
Packit |
4a16fb |
return obj->value.enumerated.item[idx];
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get value of a specified member from given data as an element of
|
|
Packit |
4a16fb |
* bytes type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param idx Index of member in the element.
|
|
Packit |
4a16fb |
* \return Value for the member.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
unsigned char snd_ctl_elem_value_get_byte(const snd_ctl_elem_value_t *obj, unsigned int idx)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < ARRAY_SIZE(obj->value.bytes.data));
|
|
Packit |
4a16fb |
return obj->value.bytes.data[idx];
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set value of a specified member to given data as an element of
|
|
Packit |
4a16fb |
* boolean type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param idx Index of member in the element.
|
|
Packit |
4a16fb |
* \param val Value for the member.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_boolean(snd_ctl_elem_value_t *obj, unsigned int idx, long val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < ARRAY_SIZE(obj->value.integer.value));
|
|
Packit |
4a16fb |
obj->value.integer.value[idx] = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set value of a specified member to given data as an element of
|
|
Packit |
4a16fb |
* integer type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param idx Index of member in the element.
|
|
Packit |
4a16fb |
* \param val Value for the member.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_integer(snd_ctl_elem_value_t *obj, unsigned int idx, long val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < ARRAY_SIZE(obj->value.integer.value));
|
|
Packit |
4a16fb |
obj->value.integer.value[idx] = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set value of a specified member to given data as an element of
|
|
Packit |
4a16fb |
* integer64 type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param idx Index of member in the element.
|
|
Packit |
4a16fb |
* \param val Value for the member.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_integer64(snd_ctl_elem_value_t *obj, unsigned int idx, long long val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < ARRAY_SIZE(obj->value.integer64.value));
|
|
Packit |
4a16fb |
obj->value.integer64.value[idx] = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set value of a specified member to given data as an element of
|
|
Packit |
4a16fb |
* enumerated type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param idx Index of member in the element.
|
|
Packit |
4a16fb |
* \param val Value for the member.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_enumerated(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned int val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < ARRAY_SIZE(obj->value.enumerated.item));
|
|
Packit |
4a16fb |
obj->value.enumerated.item[idx] = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set value for a specified member to given data as an element of byte
|
|
Packit |
4a16fb |
* type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param idx Index of member in the element.
|
|
Packit |
4a16fb |
* \param val Value for the member.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_byte(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned char val)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(idx < ARRAY_SIZE(obj->value.bytes.data));
|
|
Packit |
4a16fb |
obj->value.bytes.data[idx] = val;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set values to given data as an element of bytes type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param data Pointer for byte array.
|
|
Packit |
4a16fb |
* \param size The number of bytes included in the memory block.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_set_bytes(snd_ctl_elem_value_t *obj, void *data, size_t size)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
assert(size <= ARRAY_SIZE(obj->value.bytes.data));
|
|
Packit |
4a16fb |
memcpy(obj->value.bytes.data, data, size);
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get memory block from given data as an element of bytes type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \return Pointer for byte array.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
const void * snd_ctl_elem_value_get_bytes(const snd_ctl_elem_value_t *obj)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj);
|
|
Packit |
4a16fb |
return obj->value.bytes.data;
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Get value from given data to given pointer as an element of IEC958
|
|
Packit |
4a16fb |
* type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param ptr Pointer to IEC958 data.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_get_iec958(const snd_ctl_elem_value_t *obj, snd_aes_iec958_t *ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj && ptr);
|
|
Packit |
4a16fb |
memcpy(ptr, &obj->value.iec958, sizeof(*ptr));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|
|
Packit |
4a16fb |
/**
|
|
Packit |
4a16fb |
* \brief Set value from given pointer to given data as an element of IEC958
|
|
Packit |
4a16fb |
* type.
|
|
Packit |
4a16fb |
* \param obj Data of an element.
|
|
Packit |
4a16fb |
* \param ptr Pointer to IEC958 data.
|
|
Packit |
4a16fb |
*/
|
|
Packit |
4a16fb |
void snd_ctl_elem_value_set_iec958(snd_ctl_elem_value_t *obj, const snd_aes_iec958_t *ptr)
|
|
Packit |
4a16fb |
{
|
|
Packit |
4a16fb |
assert(obj && ptr);
|
|
Packit |
4a16fb |
memcpy(&obj->value.iec958, ptr, sizeof(obj->value.iec958));
|
|
Packit |
4a16fb |
}
|
|
Packit |
4a16fb |
|