control.c (23c18d4bfd73ee24070849faf98b3ab01263a3c4) | control.c (0fcd9f4b3c60382205e5819c456aa9ea17b6f20f) |
---|---|
1/* 2 * Routines for driver control interface 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 4 * 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 1646 unchanged lines hidden (view full) --- 1655}; 1656 1657/* 1658 * registration of the control device 1659 */ 1660static int snd_ctl_dev_register(struct snd_device *device) 1661{ 1662 struct snd_card *card = device->device_data; | 1/* 2 * Routines for driver control interface 3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 4 * 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 1646 unchanged lines hidden (view full) --- 1655}; 1656 1657/* 1658 * registration of the control device 1659 */ 1660static int snd_ctl_dev_register(struct snd_device *device) 1661{ 1662 struct snd_card *card = device->device_data; |
1663 int err, cardnum; 1664 char name[16]; | |
1665 | 1663 |
1666 if (snd_BUG_ON(!card)) 1667 return -ENXIO; 1668 cardnum = card->number; 1669 if (snd_BUG_ON(cardnum < 0 || cardnum >= SNDRV_CARDS)) 1670 return -ENXIO; 1671 sprintf(name, "controlC%i", cardnum); 1672 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1, 1673 &snd_ctl_f_ops, card, name)) < 0) 1674 return err; 1675 return 0; | 1664 return snd_register_device_for_dev(SNDRV_DEVICE_TYPE_CONTROL, card, 1665 -1, &snd_ctl_f_ops, card, 1666 &card->ctl_dev, NULL, NULL); |
1676} 1677 1678/* 1679 * disconnection of the control device 1680 */ 1681static int snd_ctl_dev_disconnect(struct snd_device *device) 1682{ 1683 struct snd_card *card = device->device_data; 1684 struct snd_ctl_file *ctl; | 1667} 1668 1669/* 1670 * disconnection of the control device 1671 */ 1672static int snd_ctl_dev_disconnect(struct snd_device *device) 1673{ 1674 struct snd_card *card = device->device_data; 1675 struct snd_ctl_file *ctl; |
1685 int err, cardnum; | |
1686 | 1676 |
1687 if (snd_BUG_ON(!card)) 1688 return -ENXIO; 1689 cardnum = card->number; 1690 if (snd_BUG_ON(cardnum < 0 || cardnum >= SNDRV_CARDS)) 1691 return -ENXIO; 1692 | |
1693 read_lock(&card->ctl_files_rwlock); 1694 list_for_each_entry(ctl, &card->ctl_files, list) { 1695 wake_up(&ctl->change_sleep); 1696 kill_fasync(&ctl->fasync, SIGIO, POLL_ERR); 1697 } 1698 read_unlock(&card->ctl_files_rwlock); 1699 | 1677 read_lock(&card->ctl_files_rwlock); 1678 list_for_each_entry(ctl, &card->ctl_files, list) { 1679 wake_up(&ctl->change_sleep); 1680 kill_fasync(&ctl->fasync, SIGIO, POLL_ERR); 1681 } 1682 read_unlock(&card->ctl_files_rwlock); 1683 |
1700 if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, 1701 card, -1)) < 0) 1702 return err; 1703 return 0; | 1684 return snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1); |
1704} 1705 1706/* 1707 * free all controls 1708 */ 1709static int snd_ctl_dev_free(struct snd_device *device) 1710{ 1711 struct snd_card *card = device->device_data; 1712 struct snd_kcontrol *control; 1713 1714 down_write(&card->controls_rwsem); 1715 while (!list_empty(&card->controls)) { 1716 control = snd_kcontrol(card->controls.next); 1717 snd_ctl_remove(card, control); 1718 } 1719 up_write(&card->controls_rwsem); | 1685} 1686 1687/* 1688 * free all controls 1689 */ 1690static int snd_ctl_dev_free(struct snd_device *device) 1691{ 1692 struct snd_card *card = device->device_data; 1693 struct snd_kcontrol *control; 1694 1695 down_write(&card->controls_rwsem); 1696 while (!list_empty(&card->controls)) { 1697 control = snd_kcontrol(card->controls.next); 1698 snd_ctl_remove(card, control); 1699 } 1700 up_write(&card->controls_rwsem); |
1701 put_device(&card->ctl_dev); |
|
1720 return 0; 1721} 1722 1723/* 1724 * create control core: 1725 * called from init.c 1726 */ 1727int snd_ctl_create(struct snd_card *card) 1728{ 1729 static struct snd_device_ops ops = { 1730 .dev_free = snd_ctl_dev_free, 1731 .dev_register = snd_ctl_dev_register, 1732 .dev_disconnect = snd_ctl_dev_disconnect, 1733 }; | 1702 return 0; 1703} 1704 1705/* 1706 * create control core: 1707 * called from init.c 1708 */ 1709int snd_ctl_create(struct snd_card *card) 1710{ 1711 static struct snd_device_ops ops = { 1712 .dev_free = snd_ctl_dev_free, 1713 .dev_register = snd_ctl_dev_register, 1714 .dev_disconnect = snd_ctl_dev_disconnect, 1715 }; |
1716 int err; |
|
1734 1735 if (snd_BUG_ON(!card)) 1736 return -ENXIO; | 1717 1718 if (snd_BUG_ON(!card)) 1719 return -ENXIO; |
1737 return snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops); | 1720 if (snd_BUG_ON(card->number < 0 || card->number >= SNDRV_CARDS)) 1721 return -ENXIO; 1722 1723 snd_device_initialize(&card->ctl_dev, card); 1724 dev_set_name(&card->ctl_dev, "controlC%d", card->number); 1725 1726 err = snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops); 1727 if (err < 0) 1728 put_device(&card->ctl_dev); 1729 return err; |
1738} 1739 1740/* 1741 * Frequently used control callbacks/helpers 1742 */ 1743 1744/** 1745 * snd_ctl_boolean_mono_info - Helper function for a standard boolean info --- 70 unchanged lines hidden --- | 1730} 1731 1732/* 1733 * Frequently used control callbacks/helpers 1734 */ 1735 1736/** 1737 * snd_ctl_boolean_mono_info - Helper function for a standard boolean info --- 70 unchanged lines hidden --- |