The highlevel control layer was rewritten and updated.

Various fixes in mixer simple layer.
Added include/list.h (from the kernel tree).
This commit is contained in:
Jaroslav Kysela 2000-08-11 19:28:43 +00:00
parent b99128d8de
commit 82102903fe
7 changed files with 382 additions and 189 deletions

View file

@ -54,10 +54,25 @@ int snd_ctl_read(snd_ctl_t *handle, snd_ctl_callbacks_t * callbacks);
* Highlevel API for controls
*/
#define LIST_HEAD_IS_DEFINED
struct list_head {
struct list_head *next, *prev;
};
typedef struct snd_hcontrol_list_stru snd_hcontrol_list_t;
typedef struct snd_hcontrol_stru snd_hcontrol_t;
struct snd_hcontrol_list_stru {
unsigned int controls_offset; /* W: first control ID to get */
unsigned int controls_request; /* W: count of control IDs to get */
unsigned int controls_count; /* R: count of available (set) controls */
unsigned int controls; /* R: count of all available controls */
snd_control_id_t *pids; /* W: IDs */
};
struct snd_hcontrol_stru {
snd_control_id_t id; /* must be always on top */
struct list_head list; /* links for list of all hcontrols */
int change: 1, /* structure change */
value: 1; /* value change */
/* event callbacks */
@ -71,18 +86,19 @@ struct snd_hcontrol_stru {
snd_ctl_t *handle; /* associated handle */
};
typedef int (snd_ctl_csort_t)(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
typedef int (snd_ctl_ccallback_rebuild_t)(snd_ctl_t *handle, void *private_data);
typedef int (snd_ctl_ccallback_add_t)(snd_ctl_t *handle, void *private_data, snd_hcontrol_t *hcontrol);
typedef int (snd_ctl_hsort_t)(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
typedef int (snd_ctl_hcallback_rebuild_t)(snd_ctl_t *handle, void *private_data);
typedef int (snd_ctl_hcallback_add_t)(snd_ctl_t *handle, void *private_data, snd_hcontrol_t *hcontrol);
int snd_ctl_cbuild(snd_ctl_t *handle, snd_ctl_csort_t *csort);
int snd_ctl_cfree(snd_ctl_t *handle);
snd_hcontrol_t *snd_ctl_cfind(snd_ctl_t *handle, snd_control_id_t *id);
int snd_ctl_csort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
int snd_ctl_cresort(snd_ctl_t *handle, snd_ctl_csort_t *csort);
int snd_ctl_ccallback_rebuild(snd_ctl_t *handle, snd_ctl_ccallback_rebuild_t *callback, void *private_data);
int snd_ctl_ccallback_add(snd_ctl_t *handle, snd_ctl_ccallback_add_t *callback, void *private_data);
int snd_ctl_cevent(snd_ctl_t *handle);
int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t *csort);
int snd_ctl_hfree(snd_ctl_t *handle);
snd_hcontrol_t *snd_ctl_hfind(snd_ctl_t *handle, snd_control_id_t *id);
int snd_ctl_hlist(snd_ctl_t *handle, snd_hcontrol_list_t *hlist);
int snd_ctl_hsort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t *csort);
int snd_ctl_hcallback_rebuild(snd_ctl_t *handle, snd_ctl_hcallback_rebuild_t *callback, void *private_data);
int snd_ctl_hcallback_add(snd_ctl_t *handle, snd_ctl_hcallback_add_t *callback, void *private_data);
int snd_ctl_hevent(snd_ctl_t *handle);
#ifdef __cplusplus
}

156
include/list.h Normal file
View file

@ -0,0 +1,156 @@
#ifndef _LIST_H
#define _LIST_H
/*
* This code was taken from the Linux 2.4.0 kernel. [jaroslav]
*/
/*
* Simple doubly linked list implementation.
*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
#ifndef LIST_HEAD_IS_DEFINED
struct list_head {
struct list_head *next, *prev;
};
#endif
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static __inline__ void __list_add(struct list_head * new,
struct list_head * prev,
struct list_head * next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
/**
* list_add - add a new entry
* @new: new entry to be added
* @head: list head to add it after
*
* Insert a new entry after the specified head.
* This is good for implementing stacks.
*/
static __inline__ void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}
/**
* list_add_tail - add a new entry
* @new: new entry to be added
* @head: list head to add it before
*
* Insert a new entry before the specified head.
* This is useful for implementing queues.
*/
static __inline__ void list_add_tail(struct list_head *new, struct list_head *head)
{
__list_add(new, head->prev, head);
}
/*
* Delete a list entry by making the prev/next entries
* point to each other.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static __inline__ void __list_del(struct list_head * prev,
struct list_head * next)
{
next->prev = prev;
prev->next = next;
}
/**
* list_del - deletes entry from list.
* @entry: the element to delete from the list.
* Note: list_empty on entry does not return true after this, the entry is in an undefined state.
*/
static __inline__ void list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
}
/**
* list_del_init - deletes entry from list and reinitialize it.
* @entry: the element to delete from the list.n
*/
static __inline__ void list_del_init(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
INIT_LIST_HEAD(entry);
}
/**
* list_empty - tests whether a list is empty
* @head: the list to test.
*/
static __inline__ int list_empty(struct list_head *head)
{
return head->next == head;
}
/**
* list_splice - join two lists
* @list: the new list to add.
* @head: the place to add it in the first list.
*/
static __inline__ void list_splice(struct list_head *list, struct list_head *head)
{
struct list_head *first = list->next;
if (first != list) {
struct list_head *last = list->prev;
struct list_head *at = head->next;
first->prev = head;
head->next = first;
last->next = at;
at->prev = last;
}
}
/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
/**
* list_for_each - iterate over a list
* @pos: the &struct list_head to use as a loop counter.
* @head: the head for your list.
*/
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
#endif /* _LIST_H */