]> git.alsa-project.org Git - alsa-lib.git/commitdiff
- added support for user control elements
authorJaroslav Kysela <perex@perex.cz>
Tue, 21 Oct 2003 17:39:14 +0000 (17:39 +0000)
committerJaroslav Kysela <perex@perex.cz>
Tue, 21 Oct 2003 17:39:14 +0000 (17:39 +0000)
include/sound/asound.h
src/Versions
src/control/control.c
src/control/control_hw.c
src/control/control_local.h

index 99547ab3e252729e596e70637b908dbff29dfea4..864369aac1b1de2b6a9eb53ddeb8634ea5a8bde1 100644 (file)
@@ -106,9 +106,10 @@ enum sndrv_hwdep_iface {
        SNDRV_HWDEP_IFACE_SSCAPE,       /* Ensoniq SoundScape ISA card (MC68EC000) */
        SNDRV_HWDEP_IFACE_VX,           /* Digigram VX cards */
        SNDRV_HWDEP_IFACE_MIXART,       /* Digigram miXart cards */
+       SNDRV_HWDEP_IFACE_USX2Y,        /* Tascam US122, US224 & US428 usb */
 
        /* Don't forget to change the following: */
-       SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_MIXART,
+       SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_USX2Y,
 };
 
 struct sndrv_hwdep_info {
@@ -682,7 +683,7 @@ struct sndrv_timer_tread {
  *                                                                          *
  ****************************************************************************/
 
-#define SNDRV_CTL_VERSION              SNDRV_PROTOCOL_VERSION(2, 0, 2)
+#define SNDRV_CTL_VERSION              SNDRV_PROTOCOL_VERSION(2, 0, 3)
 
 struct sndrv_ctl_card_info {
        int card;                       /* card number */
@@ -727,6 +728,7 @@ enum sndrv_ctl_elem_iface {
 #define SNDRV_CTL_ELEM_ACCESS_INACTIVE         (1<<8)  /* control does actually nothing, but may be updated */
 #define SNDRV_CTL_ELEM_ACCESS_LOCK             (1<<9)  /* write lock */
 #define SNDRV_CTL_ELEM_ACCESS_OWNER            (1<<10) /* write lock owner */
+#define SNDRV_CTL_ELEM_ACCESS_USER             (1<<29) /* user space element */
 #define SNDRV_CTL_ELEM_ACCESS_DINDIRECT                (1<<30) /* indirect access for matrix dimensions in the info structure */
 #define SNDRV_CTL_ELEM_ACCESS_INDIRECT         (1<<31) /* indirect access for element value in the value structure */
 
@@ -823,6 +825,9 @@ enum {
        SNDRV_CTL_IOCTL_ELEM_LOCK = _IOW('U', 0x14, struct sndrv_ctl_elem_id),
        SNDRV_CTL_IOCTL_ELEM_UNLOCK = _IOW('U', 0x15, struct sndrv_ctl_elem_id),
        SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS = _IOWR('U', 0x16, int),
+       SNDRV_CTL_IOCTL_ELEM_ADD = _IOWR('U', 0x17, struct sndrv_ctl_elem_info),
+       SNDRV_CTL_IOCTL_ELEM_REPLACE = _IOWR('U', 0x18, struct sndrv_ctl_elem_info),
+       SNDRV_CTL_IOCTL_ELEM_REMOVE = _IOWR('U', 0x19, struct sndrv_ctl_elem_id),
        SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE = _IOWR('U', 0x20, int),
        SNDRV_CTL_IOCTL_HWDEP_INFO = _IOR('U', 0x21, struct sndrv_hwdep_info),
        SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE = _IOR('U', 0x30, int),
index aedaff9a9031c6952d8160eb998070d1dc782761..52eb295c55ea3eea0f0df2d352c33d96ed008098 100644 (file)
@@ -139,5 +139,8 @@ ALSA_0.9.7 {
 ALSA_0.9.8 {
   global:
 
+    snd_ctl_elem_add;
+    snd_ctl_elem_replace;
+    snd_ctl_elem_remove;
     snd_hctl_poll_descriptors_revents;
 } ALSA_0.9.7;
index 32f3e17770b4fd7d62b2f4f21d7cdc2a4a42b9f4..9e169d2889e181b36a135523564cb90b3d27868e 100644 (file)
@@ -252,6 +252,48 @@ int snd_ctl_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
        return ctl->ops->element_info(ctl, info);
 }
 
+/**
+ * \brief Create and add an user CTL element
+ * \param ctl CTL handle
+ * \param info CTL element info
+ * \return 0 on success otherwise a negative error code
+ *
+ * Note that the new element is locked!
+ */
+int snd_ctl_elem_add(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
+{
+       assert(ctl && info && info->id.name[0]);
+       return ctl->ops->element_add(ctl, info);
+}
+
+/**
+ * \brief Replace an user CTL element
+ * \param ctl CTL handle
+ * \param info CTL element info
+ * \return 0 on success otherwise a negative error code
+ *
+ * Note that the new element is locked!
+ */
+int snd_ctl_elem_replace(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
+{
+       assert(ctl && info && info->id.name[0]);
+       return ctl->ops->element_replace(ctl, info);
+}
+
+/**
+ * \brief Remove an user CTL element
+ * \param ctl CTL handle
+ * \param id CTL element identification
+ * \return 0 on success otherwise a negative error code
+ *
+ * Note that the new element is locked!
+ */
+int snd_ctl_elem_remove(snd_ctl_t *ctl, snd_ctl_elem_id_t *id)
+{
+       assert(ctl && id && (id->name[0] || id->numid));
+       return ctl->ops->element_remove(ctl, id);
+}
+
 /**
  * \brief Get CTL element value
  * \param ctl CTL handle
index cc7c2214911c48aff4984a3aa7c07c93f495d1f8..4e9dd07f0aea1a8cd9c9387047ee33ae0873f95f 100644 (file)
@@ -39,7 +39,7 @@ const char *_snd_module_control_hw = "";
 #endif
 
 #define SNDRV_FILE_CONTROL     "/dev/snd/controlC%i"
-#define SNDRV_CTL_VERSION_MAX  SNDRV_PROTOCOL_VERSION(2, 0, 2)
+#define SNDRV_CTL_VERSION_MAX  SNDRV_PROTOCOL_VERSION(2, 0, 3)
 
 typedef struct {
        int card;
@@ -142,6 +142,30 @@ static int snd_ctl_hw_elem_info(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
        return 0;
 }
 
+static int snd_ctl_hw_elem_add(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
+{
+       snd_ctl_hw_t *hw = handle->private_data;
+       if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_ADD, info) < 0)
+               return -errno;
+       return 0;
+}
+
+static int snd_ctl_hw_elem_replace(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
+{
+       snd_ctl_hw_t *hw = handle->private_data;
+       if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_REPLACE, info) < 0)
+               return -errno;
+       return 0;
+}
+
+static int snd_ctl_hw_elem_remove(snd_ctl_t *handle, snd_ctl_elem_id_t *id)
+{
+       snd_ctl_hw_t *hw = handle->private_data;
+       if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_REMOVE, id) < 0)
+               return -errno;
+       return 0;
+}
+
 static int snd_ctl_hw_elem_read(snd_ctl_t *handle, snd_ctl_elem_value_t *control)
 {
        snd_ctl_hw_t *hw = handle->private_data;
@@ -272,6 +296,9 @@ snd_ctl_ops_t snd_ctl_hw_ops = {
        .card_info = snd_ctl_hw_card_info,
        .element_list = snd_ctl_hw_elem_list,
        .element_info = snd_ctl_hw_elem_info,
+       .element_add = snd_ctl_hw_elem_add,
+       .element_replace = snd_ctl_hw_elem_replace,
+       .element_remove = snd_ctl_hw_elem_remove,
        .element_read = snd_ctl_hw_elem_read,
        .element_write = snd_ctl_hw_elem_write,
        .element_lock = snd_ctl_hw_elem_lock,
index 80081c43e1577b1f13a7b419db8f5d939f9d2825..0c38db48c53ef9781dcb656f563c52c4c76442e7 100644 (file)
@@ -29,6 +29,9 @@ typedef struct _snd_ctl_ops {
        int (*card_info)(snd_ctl_t *handle, snd_ctl_card_info_t *info);
        int (*element_list)(snd_ctl_t *handle, snd_ctl_elem_list_t *list);
        int (*element_info)(snd_ctl_t *handle, snd_ctl_elem_info_t *info);
+       int (*element_add)(snd_ctl_t *handle, snd_ctl_elem_info_t *info);
+       int (*element_replace)(snd_ctl_t *handle, snd_ctl_elem_info_t *info);
+       int (*element_remove)(snd_ctl_t *handle, snd_ctl_elem_id_t *id);
        int (*element_read)(snd_ctl_t *handle, snd_ctl_elem_value_t *control);
        int (*element_write)(snd_ctl_t *handle, snd_ctl_elem_value_t *control);
        int (*element_lock)(snd_ctl_t *handle, snd_ctl_elem_id_t *lock);