mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-03 09:01:52 -05:00
Control API - add TLV support
snd_ctl_elem_tlv_read snd_ctl_elem_tlv_write snd_ctl_elem_tlv_command snd_ctl_elem_info_is_tlv_readable snd_ctl_elem_info_is_tlv_writable snd_ctl_elem_info_is_tlv_commandable snd_hctl_elem_tlv_read snd_hctl_elem_tlv_write snd_hctl_elem_tlv_command
This commit is contained in:
parent
408697bfe2
commit
c7a0708a23
7 changed files with 248 additions and 4 deletions
|
|
@ -200,6 +200,39 @@ static int snd_ctl_hw_elem_unlock(snd_ctl_t *handle, snd_ctl_elem_id_t *id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ctl_hw_elem_tlv(snd_ctl_t *handle, int op_flag,
|
||||
unsigned int numid,
|
||||
unsigned int *tlv, unsigned int tlv_size)
|
||||
{
|
||||
int inum;
|
||||
snd_ctl_hw_t *hw = handle->private_data;
|
||||
struct sndrv_ctl_tlv *xtlv;
|
||||
|
||||
switch (op_flag) {
|
||||
case -1: inum = SNDRV_CTL_IOCTL_TLV_COMMAND; break;
|
||||
case 0: inum = SNDRV_CTL_IOCTL_TLV_READ; break;
|
||||
case 1: inum = SNDRV_CTL_IOCTL_TLV_WRITE; break;
|
||||
default: return -EINVAL;
|
||||
}
|
||||
xtlv = malloc(sizeof(struct sndrv_ctl_tlv) + tlv_size);
|
||||
if (xtlv == NULL)
|
||||
return -ENOMEM;
|
||||
xtlv->numid = numid;
|
||||
xtlv->length = tlv_size;
|
||||
memcpy(xtlv->tlv, tlv, tlv_size);
|
||||
if (ioctl(hw->fd, inum, xtlv) < 0) {
|
||||
free(xtlv);
|
||||
return -errno;
|
||||
}
|
||||
if (op_flag == 0) {
|
||||
if (xtlv->tlv[1] + 2 * sizeof(unsigned int) > tlv_size)
|
||||
return -EFAULT;
|
||||
memcpy(tlv, xtlv->tlv, xtlv->tlv[1] + 2 * sizeof(unsigned int));
|
||||
}
|
||||
free(xtlv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_ctl_hw_hwdep_next_device(snd_ctl_t *handle, int * device)
|
||||
{
|
||||
snd_ctl_hw_t *hw = handle->private_data;
|
||||
|
|
@ -305,6 +338,7 @@ snd_ctl_ops_t snd_ctl_hw_ops = {
|
|||
.element_write = snd_ctl_hw_elem_write,
|
||||
.element_lock = snd_ctl_hw_elem_lock,
|
||||
.element_unlock = snd_ctl_hw_elem_unlock,
|
||||
.element_tlv = snd_ctl_hw_elem_tlv,
|
||||
.hwdep_next_device = snd_ctl_hw_hwdep_next_device,
|
||||
.hwdep_info = snd_ctl_hw_hwdep_info,
|
||||
.pcm_next_device = snd_ctl_hw_pcm_next_device,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue