aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-05-02 02:58:31 -0400
committerJaroslav Kysela <perex@suse.cz>2005-05-29 04:06:00 -0400
commit434b7f56872fc5783c77f362e895da8e22168325 (patch)
tree421248cb574264b68c4c432f3c5f428f69666ed1
parentca81090a00e3e7152fe1f3d7398f11d57919428e (diff)
[ALSA] usb-audio - make SB remote control device LIRC compatible
USB generic driver Add ioctls to the Sound Blaster remote control hwdep device so that it can be used with LIRC. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
-rw-r--r--sound/usb/usbmixer.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 5683ae0b5ba1..d90d6fa7431a 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -39,6 +39,18 @@
39 39
40#include "usbaudio.h" 40#include "usbaudio.h"
41 41
42#if 0
43#include <linux/lirc.h>
44#else
45/* only those symbols from lirc.h we actually need: */
46#include <linux/ioctl.h>
47#define LIRC_MODE2REC(x) ((x) << 16)
48#define LIRC_MODE_CODE 0x00000008
49#define LIRC_CAN_REC_CODE LIRC_MODE2REC(LIRC_MODE_CODE)
50#define LIRC_GET_FEATURES _IOR('i', 0x00000000, __u32)
51#define LIRC_GET_REC_MODE _IOR('i', 0x00000002, __u32)
52#define LIRC_SET_REC_MODE _IOW('i', 0x00000012, __u32)
53#endif
42 54
43/* 55/*
44 */ 56 */
@@ -1739,12 +1751,15 @@ static long snd_usb_sbrc_hwdep_read(snd_hwdep_t *hw, char __user *buf,
1739 int err; 1751 int err;
1740 u32 rc_code; 1752 u32 rc_code;
1741 1753
1742 if (count != 1) 1754 if (count != 1 && count != 4)
1743 return -EINVAL; 1755 return -EINVAL;
1744 err = wait_event_interruptible(mixer->rc_waitq, 1756 err = wait_event_interruptible(mixer->rc_waitq,
1745 (rc_code = xchg(&mixer->rc_code, 0)) != 0); 1757 (rc_code = xchg(&mixer->rc_code, 0)) != 0);
1746 if (err == 0) { 1758 if (err == 0) {
1747 err = put_user(rc_code, buf); 1759 if (count == 1)
1760 err = put_user(rc_code, buf);
1761 else
1762 err = put_user(rc_code, (u32 __user *)buf);
1748 } 1763 }
1749 return err < 0 ? err : count; 1764 return err < 0 ? err : count;
1750} 1765}
@@ -1758,6 +1773,25 @@ static unsigned int snd_usb_sbrc_hwdep_poll(snd_hwdep_t *hw, struct file *file,
1758 return mixer->rc_code ? POLLIN | POLLRDNORM : 0; 1773 return mixer->rc_code ? POLLIN | POLLRDNORM : 0;
1759} 1774}
1760 1775
1776static int snd_usb_sbrc_hwdep_ioctl(snd_hwdep_t *hw, struct file *file,
1777 unsigned int cmd, unsigned long arg)
1778{
1779 u32 __user *argp = (u32 __user *)arg;
1780 u32 mode;
1781
1782 switch (cmd) {
1783 case LIRC_GET_FEATURES:
1784 return put_user(LIRC_CAN_REC_CODE, argp);
1785 case LIRC_GET_REC_MODE:
1786 return put_user(LIRC_MODE_CODE, argp);
1787 case LIRC_SET_REC_MODE:
1788 if (get_user(mode, argp))
1789 return -EFAULT;
1790 return mode == LIRC_MODE_CODE ? 0 : -ENOSYS;
1791 }
1792 return -ENOTTY;
1793}
1794
1761static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer) 1795static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
1762{ 1796{
1763 snd_hwdep_t *hwdep; 1797 snd_hwdep_t *hwdep;
@@ -1788,6 +1822,7 @@ static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
1788 hwdep->ops.open = snd_usb_sbrc_hwdep_open; 1822 hwdep->ops.open = snd_usb_sbrc_hwdep_open;
1789 hwdep->ops.release = snd_usb_sbrc_hwdep_release; 1823 hwdep->ops.release = snd_usb_sbrc_hwdep_release;
1790 hwdep->ops.poll = snd_usb_sbrc_hwdep_poll; 1824 hwdep->ops.poll = snd_usb_sbrc_hwdep_poll;
1825 hwdep->ops.ioctl = snd_usb_sbrc_hwdep_ioctl;
1791 1826
1792 mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL); 1827 mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL);
1793 if (!mixer->rc_urb) 1828 if (!mixer->rc_urb)